angular2-all.umd.js 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("Rx"), require("rxjs/observable/fromPromise"), require("rxjs/operator/toPromise"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["Rx", "rxjs/observable/fromPromise", "rxjs/operator/toPromise"], factory);
  6. else if(typeof exports === 'object')
  7. exports["ng"] = factory(require("Rx"), require("rxjs/observable/fromPromise"), require("rxjs/operator/toPromise"));
  8. else
  9. root["ng"] = factory(root["Rx"], root["Rx"]["Observable"], root["Rx"]["Observable"]["prototype"]);
  10. })(this, function(__WEBPACK_EXTERNAL_MODULE_62__, __WEBPACK_EXTERNAL_MODULE_63__, __WEBPACK_EXTERNAL_MODULE_64__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/ // The require function
  15. /******/ function __webpack_require__(moduleId) {
  16. /******/ // Check if module is in cache
  17. /******/ if(installedModules[moduleId])
  18. /******/ return installedModules[moduleId].exports;
  19. /******/ // Create a new module (and put it into the cache)
  20. /******/ var module = installedModules[moduleId] = {
  21. /******/ exports: {},
  22. /******/ id: moduleId,
  23. /******/ loaded: false
  24. /******/ };
  25. /******/ // Execute the module function
  26. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  27. /******/ // Flag the module as loaded
  28. /******/ module.loaded = true;
  29. /******/ // Return the exports of the module
  30. /******/ return module.exports;
  31. /******/ }
  32. /******/ // expose the modules object (__webpack_modules__)
  33. /******/ __webpack_require__.m = modules;
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/ // __webpack_public_path__
  37. /******/ __webpack_require__.p = "";
  38. /******/ // Load entry module and return exports
  39. /******/ return __webpack_require__(0);
  40. /******/ })
  41. /************************************************************************/
  42. /******/ ([
  43. /* 0 */
  44. /***/ function(module, exports, __webpack_require__) {
  45. module.exports = __webpack_require__(1);
  46. /***/ },
  47. /* 1 */
  48. /***/ function(module, exports, __webpack_require__) {
  49. exports.core = __webpack_require__(2);
  50. exports.common = __webpack_require__(104);
  51. exports.compiler = __webpack_require__(147);
  52. exports.platform = {
  53. browser: __webpack_require__(179),
  54. common_dom: __webpack_require__(203)
  55. };
  56. exports.http = __webpack_require__(209);
  57. exports.router = __webpack_require__(224);
  58. exports.router_link_dsl = __webpack_require__(248);
  59. exports.instrumentation = __webpack_require__(250);
  60. exports.upgrade = __webpack_require__(251);
  61. /***/ },
  62. /* 2 */
  63. /***/ function(module, exports, __webpack_require__) {
  64. function __export(m) {
  65. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  66. }
  67. /**
  68. * @module
  69. * @description
  70. * Starting point to import all public core APIs.
  71. */
  72. __export(__webpack_require__(3));
  73. __export(__webpack_require__(57));
  74. __export(__webpack_require__(58));
  75. __export(__webpack_require__(6));
  76. __export(__webpack_require__(59));
  77. var lang_1 = __webpack_require__(5);
  78. exports.enableProdMode = lang_1.enableProdMode;
  79. var application_ref_1 = __webpack_require__(65);
  80. exports.platform = application_ref_1.platform;
  81. exports.createNgZone = application_ref_1.createNgZone;
  82. exports.PlatformRef = application_ref_1.PlatformRef;
  83. exports.ApplicationRef = application_ref_1.ApplicationRef;
  84. var application_tokens_1 = __webpack_require__(67);
  85. exports.APP_ID = application_tokens_1.APP_ID;
  86. exports.APP_COMPONENT = application_tokens_1.APP_COMPONENT;
  87. exports.APP_INITIALIZER = application_tokens_1.APP_INITIALIZER;
  88. exports.PACKAGE_ROOT_URL = application_tokens_1.PACKAGE_ROOT_URL;
  89. exports.PLATFORM_INITIALIZER = application_tokens_1.PLATFORM_INITIALIZER;
  90. __export(__webpack_require__(98));
  91. __export(__webpack_require__(99));
  92. __export(__webpack_require__(100));
  93. var debug_element_1 = __webpack_require__(101);
  94. exports.DebugElement = debug_element_1.DebugElement;
  95. exports.Scope = debug_element_1.Scope;
  96. exports.inspectElement = debug_element_1.inspectElement;
  97. exports.asNativeElements = debug_element_1.asNativeElements;
  98. __export(__webpack_require__(68));
  99. __export(__webpack_require__(24));
  100. __export(__webpack_require__(95));
  101. __export(__webpack_require__(102));
  102. __export(__webpack_require__(103));
  103. __export(__webpack_require__(16));
  104. /***/ },
  105. /* 3 */
  106. /***/ function(module, exports, __webpack_require__) {
  107. /**
  108. * This indirection is needed to free up Component, etc symbols in the public API
  109. * to be used by the decorator versions of these annotations.
  110. */
  111. var di_1 = __webpack_require__(4);
  112. exports.QueryMetadata = di_1.QueryMetadata;
  113. exports.ContentChildrenMetadata = di_1.ContentChildrenMetadata;
  114. exports.ContentChildMetadata = di_1.ContentChildMetadata;
  115. exports.ViewChildrenMetadata = di_1.ViewChildrenMetadata;
  116. exports.ViewQueryMetadata = di_1.ViewQueryMetadata;
  117. exports.ViewChildMetadata = di_1.ViewChildMetadata;
  118. exports.AttributeMetadata = di_1.AttributeMetadata;
  119. var directives_1 = __webpack_require__(23);
  120. exports.ComponentMetadata = directives_1.ComponentMetadata;
  121. exports.DirectiveMetadata = directives_1.DirectiveMetadata;
  122. exports.PipeMetadata = directives_1.PipeMetadata;
  123. exports.InputMetadata = directives_1.InputMetadata;
  124. exports.OutputMetadata = directives_1.OutputMetadata;
  125. exports.HostBindingMetadata = directives_1.HostBindingMetadata;
  126. exports.HostListenerMetadata = directives_1.HostListenerMetadata;
  127. var view_1 = __webpack_require__(56);
  128. exports.ViewMetadata = view_1.ViewMetadata;
  129. exports.ViewEncapsulation = view_1.ViewEncapsulation;
  130. var di_2 = __webpack_require__(4);
  131. var directives_2 = __webpack_require__(23);
  132. var view_2 = __webpack_require__(56);
  133. var decorators_1 = __webpack_require__(9);
  134. // TODO(alexeagle): remove the duplication of this doc. It is copied from ComponentMetadata.
  135. /**
  136. * Declare reusable UI building blocks for an application.
  137. *
  138. * Each Angular component requires a single `@Component` and at least one `@View` annotation. The
  139. * `@Component`
  140. * annotation specifies when a component is instantiated, and which properties and hostListeners it
  141. * binds to.
  142. *
  143. * When a component is instantiated, Angular
  144. * - creates a shadow DOM for the component.
  145. * - loads the selected template into the shadow DOM.
  146. * - creates all the injectable objects configured with `providers` and `viewProviders`.
  147. *
  148. * All template expressions and statements are then evaluated against the component instance.
  149. *
  150. * For details on the `@View` annotation, see {@link ViewMetadata}.
  151. *
  152. * ## Lifecycle hooks
  153. *
  154. * When the component class implements some {@link angular2/lifecycle_hooks} the callbacks are
  155. * called by the change detection at defined points in time during the life of the component.
  156. *
  157. * ### Example
  158. *
  159. * {@example core/ts/metadata/metadata.ts region='component'}
  160. */
  161. exports.Component = decorators_1.makeDecorator(directives_2.ComponentMetadata, function (fn) { return fn.View = exports.View; });
  162. // TODO(alexeagle): remove the duplication of this doc. It is copied from DirectiveMetadata.
  163. /**
  164. * Directives allow you to attach behavior to elements in the DOM.
  165. *
  166. * {@link DirectiveMetadata}s with an embedded view are called {@link ComponentMetadata}s.
  167. *
  168. * A directive consists of a single directive annotation and a controller class. When the
  169. * directive's `selector` matches
  170. * elements in the DOM, the following steps occur:
  171. *
  172. * 1. For each directive, the `ElementInjector` attempts to resolve the directive's constructor
  173. * arguments.
  174. * 2. Angular instantiates directives for each matched element using `ElementInjector` in a
  175. * depth-first order,
  176. * as declared in the HTML.
  177. *
  178. * ## Understanding How Injection Works
  179. *
  180. * There are three stages of injection resolution.
  181. * - *Pre-existing Injectors*:
  182. * - The terminal {@link Injector} cannot resolve dependencies. It either throws an error or, if
  183. * the dependency was
  184. * specified as `@Optional`, returns `null`.
  185. * - The platform injector resolves browser singleton resources, such as: cookies, title,
  186. * location, and others.
  187. * - *Component Injectors*: Each component instance has its own {@link Injector}, and they follow
  188. * the same parent-child hierarchy
  189. * as the component instances in the DOM.
  190. * - *Element Injectors*: Each component instance has a Shadow DOM. Within the Shadow DOM each
  191. * element has an `ElementInjector`
  192. * which follow the same parent-child hierarchy as the DOM elements themselves.
  193. *
  194. * When a template is instantiated, it also must instantiate the corresponding directives in a
  195. * depth-first order. The
  196. * current `ElementInjector` resolves the constructor dependencies for each directive.
  197. *
  198. * Angular then resolves dependencies as follows, according to the order in which they appear in the
  199. * {@link ViewMetadata}:
  200. *
  201. * 1. Dependencies on the current element
  202. * 2. Dependencies on element injectors and their parents until it encounters a Shadow DOM boundary
  203. * 3. Dependencies on component injectors and their parents until it encounters the root component
  204. * 4. Dependencies on pre-existing injectors
  205. *
  206. *
  207. * The `ElementInjector` can inject other directives, element-specific special objects, or it can
  208. * delegate to the parent
  209. * injector.
  210. *
  211. * To inject other directives, declare the constructor parameter as:
  212. * - `directive:DirectiveType`: a directive on the current element only
  213. * - `@Host() directive:DirectiveType`: any directive that matches the type between the current
  214. * element and the
  215. * Shadow DOM root.
  216. * - `@Query(DirectiveType) query:QueryList<DirectiveType>`: A live collection of direct child
  217. * directives.
  218. * - `@QueryDescendants(DirectiveType) query:QueryList<DirectiveType>`: A live collection of any
  219. * child directives.
  220. *
  221. * To inject element-specific special objects, declare the constructor parameter as:
  222. * - `element: ElementRef` to obtain a reference to logical element in the view.
  223. * - `viewContainer: ViewContainerRef` to control child template instantiation, for
  224. * {@link DirectiveMetadata} directives only
  225. * - `bindingPropagation: BindingPropagation` to control change detection in a more granular way.
  226. *
  227. * ### Example
  228. *
  229. * The following example demonstrates how dependency injection resolves constructor arguments in
  230. * practice.
  231. *
  232. *
  233. * Assume this HTML template:
  234. *
  235. * ```
  236. * <div dependency="1">
  237. * <div dependency="2">
  238. * <div dependency="3" my-directive>
  239. * <div dependency="4">
  240. * <div dependency="5"></div>
  241. * </div>
  242. * <div dependency="6"></div>
  243. * </div>
  244. * </div>
  245. * </div>
  246. * ```
  247. *
  248. * With the following `dependency` decorator and `SomeService` injectable class.
  249. *
  250. * ```
  251. * @Injectable()
  252. * class SomeService {
  253. * }
  254. *
  255. * @Directive({
  256. * selector: '[dependency]',
  257. * inputs: [
  258. * 'id: dependency'
  259. * ]
  260. * })
  261. * class Dependency {
  262. * id:string;
  263. * }
  264. * ```
  265. *
  266. * Let's step through the different ways in which `MyDirective` could be declared...
  267. *
  268. *
  269. * ### No injection
  270. *
  271. * Here the constructor is declared with no arguments, therefore nothing is injected into
  272. * `MyDirective`.
  273. *
  274. * ```
  275. * @Directive({ selector: '[my-directive]' })
  276. * class MyDirective {
  277. * constructor() {
  278. * }
  279. * }
  280. * ```
  281. *
  282. * This directive would be instantiated with no dependencies.
  283. *
  284. *
  285. * ### Component-level injection
  286. *
  287. * Directives can inject any injectable instance from the closest component injector or any of its
  288. * parents.
  289. *
  290. * Here, the constructor declares a parameter, `someService`, and injects the `SomeService` type
  291. * from the parent
  292. * component's injector.
  293. * ```
  294. * @Directive({ selector: '[my-directive]' })
  295. * class MyDirective {
  296. * constructor(someService: SomeService) {
  297. * }
  298. * }
  299. * ```
  300. *
  301. * This directive would be instantiated with a dependency on `SomeService`.
  302. *
  303. *
  304. * ### Injecting a directive from the current element
  305. *
  306. * Directives can inject other directives declared on the current element.
  307. *
  308. * ```
  309. * @Directive({ selector: '[my-directive]' })
  310. * class MyDirective {
  311. * constructor(dependency: Dependency) {
  312. * expect(dependency.id).toEqual(3);
  313. * }
  314. * }
  315. * ```
  316. * This directive would be instantiated with `Dependency` declared at the same element, in this case
  317. * `dependency="3"`.
  318. *
  319. * ### Injecting a directive from any ancestor elements
  320. *
  321. * Directives can inject other directives declared on any ancestor element (in the current Shadow
  322. * DOM), i.e. on the current element, the
  323. * parent element, or its parents.
  324. * ```
  325. * @Directive({ selector: '[my-directive]' })
  326. * class MyDirective {
  327. * constructor(@Host() dependency: Dependency) {
  328. * expect(dependency.id).toEqual(2);
  329. * }
  330. * }
  331. * ```
  332. *
  333. * `@Host` checks the current element, the parent, as well as its parents recursively. If
  334. * `dependency="2"` didn't
  335. * exist on the direct parent, this injection would
  336. * have returned
  337. * `dependency="1"`.
  338. *
  339. *
  340. * ### Injecting a live collection of direct child directives
  341. *
  342. *
  343. * A directive can also query for other child directives. Since parent directives are instantiated
  344. * before child directives, a directive can't simply inject the list of child directives. Instead,
  345. * the directive injects a {@link QueryList}, which updates its contents as children are added,
  346. * removed, or moved by a directive that uses a {@link ViewContainerRef} such as a `ngFor`, an
  347. * `ngIf`, or an `ngSwitch`.
  348. *
  349. * ```
  350. * @Directive({ selector: '[my-directive]' })
  351. * class MyDirective {
  352. * constructor(@Query(Dependency) dependencies:QueryList<Dependency>) {
  353. * }
  354. * }
  355. * ```
  356. *
  357. * This directive would be instantiated with a {@link QueryList} which contains `Dependency` 4 and
  358. * 6. Here, `Dependency` 5 would not be included, because it is not a direct child.
  359. *
  360. * ### Injecting a live collection of descendant directives
  361. *
  362. * By passing the descendant flag to `@Query` above, we can include the children of the child
  363. * elements.
  364. *
  365. * ```
  366. * @Directive({ selector: '[my-directive]' })
  367. * class MyDirective {
  368. * constructor(@Query(Dependency, {descendants: true}) dependencies:QueryList<Dependency>) {
  369. * }
  370. * }
  371. * ```
  372. *
  373. * This directive would be instantiated with a Query which would contain `Dependency` 4, 5 and 6.
  374. *
  375. * ### Optional injection
  376. *
  377. * The normal behavior of directives is to return an error when a specified dependency cannot be
  378. * resolved. If you
  379. * would like to inject `null` on unresolved dependency instead, you can annotate that dependency
  380. * with `@Optional()`.
  381. * This explicitly permits the author of a template to treat some of the surrounding directives as
  382. * optional.
  383. *
  384. * ```
  385. * @Directive({ selector: '[my-directive]' })
  386. * class MyDirective {
  387. * constructor(@Optional() dependency:Dependency) {
  388. * }
  389. * }
  390. * ```
  391. *
  392. * This directive would be instantiated with a `Dependency` directive found on the current element.
  393. * If none can be
  394. * found, the injector supplies `null` instead of throwing an error.
  395. *
  396. * ### Example
  397. *
  398. * Here we use a decorator directive to simply define basic tool-tip behavior.
  399. *
  400. * ```
  401. * @Directive({
  402. * selector: '[tooltip]',
  403. * inputs: [
  404. * 'text: tooltip'
  405. * ],
  406. * host: {
  407. * '(mouseenter)': 'onMouseEnter()',
  408. * '(mouseleave)': 'onMouseLeave()'
  409. * }
  410. * })
  411. * class Tooltip{
  412. * text:string;
  413. * overlay:Overlay; // NOT YET IMPLEMENTED
  414. * overlayManager:OverlayManager; // NOT YET IMPLEMENTED
  415. *
  416. * constructor(overlayManager:OverlayManager) {
  417. * this.overlay = overlay;
  418. * }
  419. *
  420. * onMouseEnter() {
  421. * // exact signature to be determined
  422. * this.overlay = this.overlayManager.open(text, ...);
  423. * }
  424. *
  425. * onMouseLeave() {
  426. * this.overlay.close();
  427. * this.overlay = null;
  428. * }
  429. * }
  430. * ```
  431. * In our HTML template, we can then add this behavior to a `<div>` or any other element with the
  432. * `tooltip` selector,
  433. * like so:
  434. *
  435. * ```
  436. * <div tooltip="some text here"></div>
  437. * ```
  438. *
  439. * Directives can also control the instantiation, destruction, and positioning of inline template
  440. * elements:
  441. *
  442. * A directive uses a {@link ViewContainerRef} to instantiate, insert, move, and destroy views at
  443. * runtime.
  444. * The {@link ViewContainerRef} is created as a result of `<template>` element, and represents a
  445. * location in the current view
  446. * where these actions are performed.
  447. *
  448. * Views are always created as children of the current {@link ViewMetadata}, and as siblings of the
  449. * `<template>` element. Thus a
  450. * directive in a child view cannot inject the directive that created it.
  451. *
  452. * Since directives that create views via ViewContainers are common in Angular, and using the full
  453. * `<template>` element syntax is wordy, Angular
  454. * also supports a shorthand notation: `<li *foo="bar">` and `<li template="foo: bar">` are
  455. * equivalent.
  456. *
  457. * Thus,
  458. *
  459. * ```
  460. * <ul>
  461. * <li *foo="bar" title="text"></li>
  462. * </ul>
  463. * ```
  464. *
  465. * Expands in use to:
  466. *
  467. * ```
  468. * <ul>
  469. * <template [foo]="bar">
  470. * <li title="text"></li>
  471. * </template>
  472. * </ul>
  473. * ```
  474. *
  475. * Notice that although the shorthand places `*foo="bar"` within the `<li>` element, the binding for
  476. * the directive
  477. * controller is correctly instantiated on the `<template>` element rather than the `<li>` element.
  478. *
  479. * ## Lifecycle hooks
  480. *
  481. * When the directive class implements some {@link angular2/lifecycle_hooks} the callbacks are
  482. * called by the change detection at defined points in time during the life of the directive.
  483. *
  484. * ### Example
  485. *
  486. * Let's suppose we want to implement the `unless` behavior, to conditionally include a template.
  487. *
  488. * Here is a simple directive that triggers on an `unless` selector:
  489. *
  490. * ```
  491. * @Directive({
  492. * selector: '[unless]',
  493. * inputs: ['unless']
  494. * })
  495. * export class Unless {
  496. * viewContainer: ViewContainerRef;
  497. * templateRef: TemplateRef;
  498. * prevCondition: boolean;
  499. *
  500. * constructor(viewContainer: ViewContainerRef, templateRef: TemplateRef) {
  501. * this.viewContainer = viewContainer;
  502. * this.templateRef = templateRef;
  503. * this.prevCondition = null;
  504. * }
  505. *
  506. * set unless(newCondition) {
  507. * if (newCondition && (isBlank(this.prevCondition) || !this.prevCondition)) {
  508. * this.prevCondition = true;
  509. * this.viewContainer.clear();
  510. * } else if (!newCondition && (isBlank(this.prevCondition) || this.prevCondition)) {
  511. * this.prevCondition = false;
  512. * this.viewContainer.create(this.templateRef);
  513. * }
  514. * }
  515. * }
  516. * ```
  517. *
  518. * We can then use this `unless` selector in a template:
  519. * ```
  520. * <ul>
  521. * <li *unless="expr"></li>
  522. * </ul>
  523. * ```
  524. *
  525. * Once the directive instantiates the child view, the shorthand notation for the template expands
  526. * and the result is:
  527. *
  528. * ```
  529. * <ul>
  530. * <template [unless]="exp">
  531. * <li></li>
  532. * </template>
  533. * <li></li>
  534. * </ul>
  535. * ```
  536. *
  537. * Note also that although the `<li></li>` template still exists inside the `<template></template>`,
  538. * the instantiated
  539. * view occurs on the second `<li></li>` which is a sibling to the `<template>` element.
  540. */
  541. exports.Directive = decorators_1.makeDecorator(directives_2.DirectiveMetadata);
  542. // TODO(alexeagle): remove the duplication of this doc. It is copied from ViewMetadata.
  543. /**
  544. * Metadata properties available for configuring Views.
  545. *
  546. * Each Angular component requires a single `@Component` and at least one `@View` annotation. The
  547. * `@View` annotation specifies the HTML template to use, and lists the directives that are active
  548. * within the template.
  549. *
  550. * When a component is instantiated, the template is loaded into the component's shadow root, and
  551. * the expressions and statements in the template are evaluated against the component.
  552. *
  553. * For details on the `@Component` annotation, see {@link ComponentMetadata}.
  554. *
  555. * ### Example
  556. *
  557. * ```
  558. * @Component({
  559. * selector: 'greet',
  560. * template: 'Hello {{name}}!',
  561. * directives: [GreetUser, Bold]
  562. * })
  563. * class Greet {
  564. * name: string;
  565. *
  566. * constructor() {
  567. * this.name = 'World';
  568. * }
  569. * }
  570. * ```
  571. */
  572. exports.View = decorators_1.makeDecorator(view_2.ViewMetadata, function (fn) { return fn.View = exports.View; });
  573. /**
  574. * Specifies that a constant attribute value should be injected.
  575. *
  576. * The directive can inject constant string literals of host element attributes.
  577. *
  578. * ### Example
  579. *
  580. * Suppose we have an `<input>` element and want to know its `type`.
  581. *
  582. * ```html
  583. * <input type="text">
  584. * ```
  585. *
  586. * A decorator can inject string literal `text` like so:
  587. *
  588. * {@example core/ts/metadata/metadata.ts region='attributeMetadata'}
  589. */
  590. exports.Attribute = decorators_1.makeParamDecorator(di_2.AttributeMetadata);
  591. // TODO(alexeagle): remove the duplication of this doc. It is copied from QueryMetadata.
  592. /**
  593. * Declares an injectable parameter to be a live list of directives or variable
  594. * bindings from the content children of a directive.
  595. *
  596. * ### Example ([live demo](http://plnkr.co/edit/lY9m8HLy7z06vDoUaSN2?p=preview))
  597. *
  598. * Assume that `<tabs>` component would like to get a list its children `<pane>`
  599. * components as shown in this example:
  600. *
  601. * ```html
  602. * <tabs>
  603. * <pane title="Overview">...</pane>
  604. * <pane *ngFor="#o of objects" [title]="o.title">{{o.text}}</pane>
  605. * </tabs>
  606. * ```
  607. *
  608. * The preferred solution is to query for `Pane` directives using this decorator.
  609. *
  610. * ```javascript
  611. * @Component({
  612. * selector: 'pane',
  613. * inputs: ['title']
  614. * })
  615. * class Pane {
  616. * title:string;
  617. * }
  618. *
  619. * @Component({
  620. * selector: 'tabs',
  621. * template: `
  622. * <ul>
  623. * <li *ngFor="#pane of panes">{{pane.title}}</li>
  624. * </ul>
  625. * <content></content>
  626. * `
  627. * })
  628. * class Tabs {
  629. * panes: QueryList<Pane>;
  630. * constructor(@Query(Pane) panes:QueryList<Pane>) {
  631. * this.panes = panes;
  632. * }
  633. * }
  634. * ```
  635. *
  636. * A query can look for variable bindings by passing in a string with desired binding symbol.
  637. *
  638. * ### Example ([live demo](http://plnkr.co/edit/sT2j25cH1dURAyBRCKx1?p=preview))
  639. * ```html
  640. * <seeker>
  641. * <div #findme>...</div>
  642. * </seeker>
  643. *
  644. * @Component({ selector: 'foo' })
  645. * class seeker {
  646. * constructor(@Query('findme') elList: QueryList<ElementRef>) {...}
  647. * }
  648. * ```
  649. *
  650. * In this case the object that is injected depend on the type of the variable
  651. * binding. It can be an ElementRef, a directive or a component.
  652. *
  653. * Passing in a comma separated list of variable bindings will query for all of them.
  654. *
  655. * ```html
  656. * <seeker>
  657. * <div #findMe>...</div>
  658. * <div #findMeToo>...</div>
  659. * </seeker>
  660. *
  661. * @Component({
  662. * selector: 'foo'
  663. * })
  664. * class Seeker {
  665. * constructor(@Query('findMe, findMeToo') elList: QueryList<ElementRef>) {...}
  666. * }
  667. * ```
  668. *
  669. * Configure whether query looks for direct children or all descendants
  670. * of the querying element, by using the `descendants` parameter.
  671. * It is set to `false` by default.
  672. *
  673. * ### Example ([live demo](http://plnkr.co/edit/wtGeB977bv7qvA5FTYl9?p=preview))
  674. * ```html
  675. * <container #first>
  676. * <item>a</item>
  677. * <item>b</item>
  678. * <container #second>
  679. * <item>c</item>
  680. * </container>
  681. * </container>
  682. * ```
  683. *
  684. * When querying for items, the first container will see only `a` and `b` by default,
  685. * but with `Query(TextDirective, {descendants: true})` it will see `c` too.
  686. *
  687. * The queried directives are kept in a depth-first pre-order with respect to their
  688. * positions in the DOM.
  689. *
  690. * Query does not look deep into any subcomponent views.
  691. *
  692. * Query is updated as part of the change-detection cycle. Since change detection
  693. * happens after construction of a directive, QueryList will always be empty when observed in the
  694. * constructor.
  695. *
  696. * The injected object is an unmodifiable live list.
  697. * See {@link QueryList} for more details.
  698. */
  699. exports.Query = decorators_1.makeParamDecorator(di_2.QueryMetadata);
  700. // TODO(alexeagle): remove the duplication of this doc. It is copied from ContentChildrenMetadata.
  701. /**
  702. * Configures a content query.
  703. *
  704. * Content queries are set before the `ngAfterContentInit` callback is called.
  705. *
  706. * ### Example
  707. *
  708. * ```
  709. * @Directive({
  710. * selector: 'someDir'
  711. * })
  712. * class SomeDir {
  713. * @ContentChildren(ChildDirective) contentChildren: QueryList<ChildDirective>;
  714. *
  715. * ngAfterContentInit() {
  716. * // contentChildren is set
  717. * }
  718. * }
  719. * ```
  720. */
  721. exports.ContentChildren = decorators_1.makePropDecorator(di_2.ContentChildrenMetadata);
  722. // TODO(alexeagle): remove the duplication of this doc. It is copied from ContentChildMetadata.
  723. /**
  724. * Configures a content query.
  725. *
  726. * Content queries are set before the `ngAfterContentInit` callback is called.
  727. *
  728. * ### Example
  729. *
  730. * ```
  731. * @Directive({
  732. * selector: 'someDir'
  733. * })
  734. * class SomeDir {
  735. * @ContentChild(ChildDirective) contentChild;
  736. *
  737. * ngAfterContentInit() {
  738. * // contentChild is set
  739. * }
  740. * }
  741. * ```
  742. */
  743. exports.ContentChild = decorators_1.makePropDecorator(di_2.ContentChildMetadata);
  744. // TODO(alexeagle): remove the duplication of this doc. It is copied from ViewChildrenMetadata.
  745. /**
  746. * Configures a view query.
  747. *
  748. * View queries are set before the `ngAfterViewInit` callback is called.
  749. *
  750. * ### Example
  751. *
  752. * ```
  753. * @Component({
  754. * selector: 'someDir',
  755. * templateUrl: 'someTemplate',
  756. * directives: [ItemDirective]
  757. * })
  758. * class SomeDir {
  759. * @ViewChildren(ItemDirective) viewChildren: QueryList<ItemDirective>;
  760. *
  761. * ngAfterViewInit() {
  762. * // viewChildren is set
  763. * }
  764. * }
  765. * ```
  766. */
  767. exports.ViewChildren = decorators_1.makePropDecorator(di_2.ViewChildrenMetadata);
  768. // TODO(alexeagle): remove the duplication of this doc. It is copied from ViewChildMetadata.
  769. /**
  770. * Configures a view query.
  771. *
  772. * View queries are set before the `ngAfterViewInit` callback is called.
  773. *
  774. * ### Example
  775. *
  776. * ```
  777. * @Component({
  778. * selector: 'someDir',
  779. * templateUrl: 'someTemplate',
  780. * directives: [ItemDirective]
  781. * })
  782. * class SomeDir {
  783. * @ViewChild(ItemDirective) viewChild:ItemDirective;
  784. *
  785. * ngAfterViewInit() {
  786. * // viewChild is set
  787. * }
  788. * }
  789. * ```
  790. */
  791. exports.ViewChild = decorators_1.makePropDecorator(di_2.ViewChildMetadata);
  792. // TODO(alexeagle): remove the duplication of this doc. It is copied from ViewQueryMetadata.
  793. /**
  794. * Similar to {@link QueryMetadata}, but querying the component view, instead of
  795. * the content children.
  796. *
  797. * ### Example ([live demo](http://plnkr.co/edit/eNsFHDf7YjyM6IzKxM1j?p=preview))
  798. *
  799. * ```javascript
  800. * @Component({...})
  801. * @View({
  802. * template: `
  803. * <item> a </item>
  804. * <item> b </item>
  805. * <item> c </item>
  806. * `
  807. * })
  808. * class MyComponent {
  809. * shown: boolean;
  810. *
  811. * constructor(private @Query(Item) items:QueryList<Item>) {
  812. * items.onChange(() => console.log(items.length));
  813. * }
  814. * }
  815. * ```
  816. *
  817. * Supports the same querying parameters as {@link QueryMetadata}, except
  818. * `descendants`. This always queries the whole view.
  819. *
  820. * As `shown` is flipped between true and false, items will contain zero of one
  821. * items.
  822. *
  823. * Specifies that a {@link QueryList} should be injected.
  824. *
  825. * The injected object is an iterable and observable live list.
  826. * See {@link QueryList} for more details.
  827. */
  828. exports.ViewQuery = decorators_1.makeParamDecorator(di_2.ViewQueryMetadata);
  829. // TODO(alexeagle): remove the duplication of this doc. It is copied from PipeMetadata.
  830. /**
  831. * Declare reusable pipe function.
  832. *
  833. * ### Example
  834. *
  835. * {@example core/ts/metadata/metadata.ts region='pipe'}
  836. */
  837. exports.Pipe = decorators_1.makeDecorator(directives_2.PipeMetadata);
  838. // TODO(alexeagle): remove the duplication of this doc. It is copied from InputMetadata.
  839. /**
  840. * Declares a data-bound input property.
  841. *
  842. * Angular automatically updates data-bound properties during change detection.
  843. *
  844. * `InputMetadata` takes an optional parameter that specifies the name
  845. * used when instantiating a component in the template. When not provided,
  846. * the name of the decorated property is used.
  847. *
  848. * ### Example
  849. *
  850. * The following example creates a component with two input properties.
  851. *
  852. * ```typescript
  853. * @Component({
  854. * selector: 'bank-account',
  855. * template: `
  856. * Bank Name: {{bankName}}
  857. * Account Id: {{id}}
  858. * `
  859. * })
  860. * class BankAccount {
  861. * @Input() bankName: string;
  862. * @Input('account-id') id: string;
  863. *
  864. * // this property is not bound, and won't be automatically updated by Angular
  865. * normalizedBankName: string;
  866. * }
  867. *
  868. * @Component({
  869. * selector: 'app',
  870. * template: `
  871. * <bank-account bank-name="RBC" account-id="4747"></bank-account>
  872. * `,
  873. * directives: [BankAccount]
  874. * })
  875. * class App {}
  876. *
  877. * bootstrap(App);
  878. * ```
  879. */
  880. exports.Input = decorators_1.makePropDecorator(directives_2.InputMetadata);
  881. // TODO(alexeagle): remove the duplication of this doc. It is copied from OutputMetadata.
  882. /**
  883. * Declares an event-bound output property.
  884. *
  885. * When an output property emits an event, an event handler attached to that event
  886. * the template is invoked.
  887. *
  888. * `OutputMetadata` takes an optional parameter that specifies the name
  889. * used when instantiating a component in the template. When not provided,
  890. * the name of the decorated property is used.
  891. *
  892. * ### Example
  893. *
  894. * ```typescript
  895. * @Directive({
  896. * selector: 'interval-dir',
  897. * })
  898. * class IntervalDir {
  899. * @Output() everySecond = new EventEmitter();
  900. * @Output('everyFiveSeconds') five5Secs = new EventEmitter();
  901. *
  902. * constructor() {
  903. * setInterval(() => this.everySecond.emit("event"), 1000);
  904. * setInterval(() => this.five5Secs.emit("event"), 5000);
  905. * }
  906. * }
  907. *
  908. * @Component({
  909. * selector: 'app',
  910. * template: `
  911. * <interval-dir (every-second)="everySecond()" (every-five-seconds)="everyFiveSeconds()">
  912. * </interval-dir>
  913. * `,
  914. * directives: [IntervalDir]
  915. * })
  916. * class App {
  917. * everySecond() { console.log('second'); }
  918. * everyFiveSeconds() { console.log('five seconds'); }
  919. * }
  920. * bootstrap(App);
  921. * ```
  922. */
  923. exports.Output = decorators_1.makePropDecorator(directives_2.OutputMetadata);
  924. // TODO(alexeagle): remove the duplication of this doc. It is copied from HostBindingMetadata.
  925. /**
  926. * Declares a host property binding.
  927. *
  928. * Angular automatically checks host property bindings during change detection.
  929. * If a binding changes, it will update the host element of the directive.
  930. *
  931. * `HostBindingMetadata` takes an optional parameter that specifies the property
  932. * name of the host element that will be updated. When not provided,
  933. * the class property name is used.
  934. *
  935. * ### Example
  936. *
  937. * The following example creates a directive that sets the `valid` and `invalid` classes
  938. * on the DOM element that has ngModel directive on it.
  939. *
  940. * ```typescript
  941. * @Directive({selector: '[ngModel]'})
  942. * class NgModelStatus {
  943. * constructor(public control:NgModel) {}
  944. * @HostBinding('[class.valid]') get valid { return this.control.valid; }
  945. * @HostBinding('[class.invalid]') get invalid { return this.control.invalid; }
  946. * }
  947. *
  948. * @Component({
  949. * selector: 'app',
  950. * template: `<input [(ngModel)]="prop">`,
  951. * directives: [FORM_DIRECTIVES, NgModelStatus]
  952. * })
  953. * class App {
  954. * prop;
  955. * }
  956. *
  957. * bootstrap(App);
  958. * ```
  959. */
  960. exports.HostBinding = decorators_1.makePropDecorator(directives_2.HostBindingMetadata);
  961. // TODO(alexeagle): remove the duplication of this doc. It is copied from HostListenerMetadata.
  962. /**
  963. * Declares a host listener.
  964. *
  965. * Angular will invoke the decorated method when the host element emits the specified event.
  966. *
  967. * If the decorated method returns `false`, then `preventDefault` is applied on the DOM
  968. * event.
  969. *
  970. * ### Example
  971. *
  972. * The following example declares a directive that attaches a click listener to the button and
  973. * counts clicks.
  974. *
  975. * ```typescript
  976. * @Directive({selector: 'button[counting]'})
  977. * class CountClicks {
  978. * numberOfClicks = 0;
  979. *
  980. * @HostListener('click', ['$event.target'])
  981. * onClick(btn) {
  982. * console.log("button", btn, "number of clicks:", this.numberOfClicks++);
  983. * }
  984. * }
  985. *
  986. * @Component({
  987. * selector: 'app',
  988. * template: `<button counting>Increment</button>`,
  989. * directives: [CountClicks]
  990. * })
  991. * class App {}
  992. *
  993. * bootstrap(App);
  994. * ```
  995. */
  996. exports.HostListener = decorators_1.makePropDecorator(directives_2.HostListenerMetadata);
  997. /***/ },
  998. /* 4 */
  999. /***/ function(module, exports, __webpack_require__) {
  1000. var __extends = (this && this.__extends) || function (d, b) {
  1001. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1002. function __() { this.constructor = d; }
  1003. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1004. };
  1005. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1006. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1007. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1008. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  1009. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1010. };
  1011. var __metadata = (this && this.__metadata) || function (k, v) {
  1012. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  1013. };
  1014. var lang_1 = __webpack_require__(5);
  1015. var di_1 = __webpack_require__(6);
  1016. var metadata_1 = __webpack_require__(7);
  1017. /**
  1018. * Specifies that a constant attribute value should be injected.
  1019. *
  1020. * The directive can inject constant string literals of host element attributes.
  1021. *
  1022. * ### Example
  1023. *
  1024. * Suppose we have an `<input>` element and want to know its `type`.
  1025. *
  1026. * ```html
  1027. * <input type="text">
  1028. * ```
  1029. *
  1030. * A decorator can inject string literal `text` like so:
  1031. *
  1032. * {@example core/ts/metadata/metadata.ts region='attributeMetadata'}
  1033. */
  1034. var AttributeMetadata = (function (_super) {
  1035. __extends(AttributeMetadata, _super);
  1036. function AttributeMetadata(attributeName) {
  1037. _super.call(this);
  1038. this.attributeName = attributeName;
  1039. }
  1040. Object.defineProperty(AttributeMetadata.prototype, "token", {
  1041. get: function () {
  1042. // Normally one would default a token to a type of an injected value but here
  1043. // the type of a variable is "string" and we can't use primitive type as a return value
  1044. // so we use instance of Attribute instead. This doesn't matter much in practice as arguments
  1045. // with @Attribute annotation are injected by ElementInjector that doesn't take tokens into
  1046. // account.
  1047. return this;
  1048. },
  1049. enumerable: true,
  1050. configurable: true
  1051. });
  1052. AttributeMetadata.prototype.toString = function () { return "@Attribute(" + lang_1.stringify(this.attributeName) + ")"; };
  1053. AttributeMetadata = __decorate([
  1054. lang_1.CONST(),
  1055. __metadata('design:paramtypes', [String])
  1056. ], AttributeMetadata);
  1057. return AttributeMetadata;
  1058. })(metadata_1.DependencyMetadata);
  1059. exports.AttributeMetadata = AttributeMetadata;
  1060. /**
  1061. * Declares an injectable parameter to be a live list of directives or variable
  1062. * bindings from the content children of a directive.
  1063. *
  1064. * ### Example ([live demo](http://plnkr.co/edit/lY9m8HLy7z06vDoUaSN2?p=preview))
  1065. *
  1066. * Assume that `<tabs>` component would like to get a list its children `<pane>`
  1067. * components as shown in this example:
  1068. *
  1069. * ```html
  1070. * <tabs>
  1071. * <pane title="Overview">...</pane>
  1072. * <pane *ngFor="#o of objects" [title]="o.title">{{o.text}}</pane>
  1073. * </tabs>
  1074. * ```
  1075. *
  1076. * The preferred solution is to query for `Pane` directives using this decorator.
  1077. *
  1078. * ```javascript
  1079. * @Component({
  1080. * selector: 'pane',
  1081. * inputs: ['title']
  1082. * })
  1083. * class Pane {
  1084. * title:string;
  1085. * }
  1086. *
  1087. * @Component({
  1088. * selector: 'tabs',
  1089. * template: `
  1090. * <ul>
  1091. * <li *ngFor="#pane of panes">{{pane.title}}</li>
  1092. * </ul>
  1093. * <content></content>
  1094. * `
  1095. * })
  1096. * class Tabs {
  1097. * panes: QueryList<Pane>;
  1098. * constructor(@Query(Pane) panes:QueryList<Pane>) {
  1099. * this.panes = panes;
  1100. * }
  1101. * }
  1102. * ```
  1103. *
  1104. * A query can look for variable bindings by passing in a string with desired binding symbol.
  1105. *
  1106. * ### Example ([live demo](http://plnkr.co/edit/sT2j25cH1dURAyBRCKx1?p=preview))
  1107. * ```html
  1108. * <seeker>
  1109. * <div #findme>...</div>
  1110. * </seeker>
  1111. *
  1112. * @Component({ selector: 'seeker' })
  1113. * class Seeker {
  1114. * constructor(@Query('findme') elList: QueryList<ElementRef>) {...}
  1115. * }
  1116. * ```
  1117. *
  1118. * In this case the object that is injected depend on the type of the variable
  1119. * binding. It can be an ElementRef, a directive or a component.
  1120. *
  1121. * Passing in a comma separated list of variable bindings will query for all of them.
  1122. *
  1123. * ```html
  1124. * <seeker>
  1125. * <div #find-me>...</div>
  1126. * <div #find-me-too>...</div>
  1127. * </seeker>
  1128. *
  1129. * @Component({
  1130. * selector: 'seeker'
  1131. * })
  1132. * class Seeker {
  1133. * constructor(@Query('findMe, findMeToo') elList: QueryList<ElementRef>) {...}
  1134. * }
  1135. * ```
  1136. *
  1137. * Configure whether query looks for direct children or all descendants
  1138. * of the querying element, by using the `descendants` parameter.
  1139. * It is set to `false` by default.
  1140. *
  1141. * ### Example ([live demo](http://plnkr.co/edit/wtGeB977bv7qvA5FTYl9?p=preview))
  1142. * ```html
  1143. * <container #first>
  1144. * <item>a</item>
  1145. * <item>b</item>
  1146. * <container #second>
  1147. * <item>c</item>
  1148. * </container>
  1149. * </container>
  1150. * ```
  1151. *
  1152. * When querying for items, the first container will see only `a` and `b` by default,
  1153. * but with `Query(TextDirective, {descendants: true})` it will see `c` too.
  1154. *
  1155. * The queried directives are kept in a depth-first pre-order with respect to their
  1156. * positions in the DOM.
  1157. *
  1158. * Query does not look deep into any subcomponent views.
  1159. *
  1160. * Query is updated as part of the change-detection cycle. Since change detection
  1161. * happens after construction of a directive, QueryList will always be empty when observed in the
  1162. * constructor.
  1163. *
  1164. * The injected object is an unmodifiable live list.
  1165. * See {@link QueryList} for more details.
  1166. */
  1167. var QueryMetadata = (function (_super) {
  1168. __extends(QueryMetadata, _super);
  1169. function QueryMetadata(_selector, _a) {
  1170. var _b = _a === void 0 ? {} : _a, _c = _b.descendants, descendants = _c === void 0 ? false : _c, _d = _b.first, first = _d === void 0 ? false : _d;
  1171. _super.call(this);
  1172. this._selector = _selector;
  1173. this.descendants = descendants;
  1174. this.first = first;
  1175. }
  1176. Object.defineProperty(QueryMetadata.prototype, "isViewQuery", {
  1177. /**
  1178. * always `false` to differentiate it with {@link ViewQueryMetadata}.
  1179. */
  1180. get: function () { return false; },
  1181. enumerable: true,
  1182. configurable: true
  1183. });
  1184. Object.defineProperty(QueryMetadata.prototype, "selector", {
  1185. /**
  1186. * what this is querying for.
  1187. */
  1188. get: function () { return di_1.resolveForwardRef(this._selector); },
  1189. enumerable: true,
  1190. configurable: true
  1191. });
  1192. Object.defineProperty(QueryMetadata.prototype, "isVarBindingQuery", {
  1193. /**
  1194. * whether this is querying for a variable binding or a directive.
  1195. */
  1196. get: function () { return lang_1.isString(this.selector); },
  1197. enumerable: true,
  1198. configurable: true
  1199. });
  1200. Object.defineProperty(QueryMetadata.prototype, "varBindings", {
  1201. /**
  1202. * returns a list of variable bindings this is querying for.
  1203. * Only applicable if this is a variable bindings query.
  1204. */
  1205. get: function () { return this.selector.split(','); },
  1206. enumerable: true,
  1207. configurable: true
  1208. });
  1209. QueryMetadata.prototype.toString = function () { return "@Query(" + lang_1.stringify(this.selector) + ")"; };
  1210. QueryMetadata = __decorate([
  1211. lang_1.CONST(),
  1212. __metadata('design:paramtypes', [Object, Object])
  1213. ], QueryMetadata);
  1214. return QueryMetadata;
  1215. })(metadata_1.DependencyMetadata);
  1216. exports.QueryMetadata = QueryMetadata;
  1217. // TODO: add an example after ContentChildren and ViewChildren are in master
  1218. /**
  1219. * Configures a content query.
  1220. *
  1221. * Content queries are set before the `ngAfterContentInit` callback is called.
  1222. *
  1223. * ### Example
  1224. *
  1225. * ```
  1226. * @Directive({
  1227. * selector: 'someDir'
  1228. * })
  1229. * class SomeDir {
  1230. * @ContentChildren(ChildDirective) contentChildren: QueryList<ChildDirective>;
  1231. *
  1232. * ngAfterContentInit() {
  1233. * // contentChildren is set
  1234. * }
  1235. * }
  1236. * ```
  1237. */
  1238. var ContentChildrenMetadata = (function (_super) {
  1239. __extends(ContentChildrenMetadata, _super);
  1240. function ContentChildrenMetadata(_selector, _a) {
  1241. var _b = (_a === void 0 ? {} : _a).descendants, descendants = _b === void 0 ? false : _b;
  1242. _super.call(this, _selector, { descendants: descendants });
  1243. }
  1244. ContentChildrenMetadata = __decorate([
  1245. lang_1.CONST(),
  1246. __metadata('design:paramtypes', [Object, Object])
  1247. ], ContentChildrenMetadata);
  1248. return ContentChildrenMetadata;
  1249. })(QueryMetadata);
  1250. exports.ContentChildrenMetadata = ContentChildrenMetadata;
  1251. // TODO: add an example after ContentChild and ViewChild are in master
  1252. /**
  1253. * Configures a content query.
  1254. *
  1255. * Content queries are set before the `ngAfterContentInit` callback is called.
  1256. *
  1257. * ### Example
  1258. *
  1259. * ```
  1260. * @Directive({
  1261. * selector: 'someDir'
  1262. * })
  1263. * class SomeDir {
  1264. * @ContentChild(ChildDirective) contentChild;
  1265. *
  1266. * ngAfterContentInit() {
  1267. * // contentChild is set
  1268. * }
  1269. * }
  1270. * ```
  1271. */
  1272. var ContentChildMetadata = (function (_super) {
  1273. __extends(ContentChildMetadata, _super);
  1274. function ContentChildMetadata(_selector) {
  1275. _super.call(this, _selector, { descendants: true, first: true });
  1276. }
  1277. ContentChildMetadata = __decorate([
  1278. lang_1.CONST(),
  1279. __metadata('design:paramtypes', [Object])
  1280. ], ContentChildMetadata);
  1281. return ContentChildMetadata;
  1282. })(QueryMetadata);
  1283. exports.ContentChildMetadata = ContentChildMetadata;
  1284. /**
  1285. * Similar to {@link QueryMetadata}, but querying the component view, instead of
  1286. * the content children.
  1287. *
  1288. * ### Example ([live demo](http://plnkr.co/edit/eNsFHDf7YjyM6IzKxM1j?p=preview))
  1289. *
  1290. * ```javascript
  1291. * @Component({...})
  1292. * @View({
  1293. * template: `
  1294. * <item> a </item>
  1295. * <item> b </item>
  1296. * <item> c </item>
  1297. * `
  1298. * })
  1299. * class MyComponent {
  1300. * shown: boolean;
  1301. *
  1302. * constructor(private @Query(Item) items:QueryList<Item>) {
  1303. * items.onChange(() => console.log(items.length));
  1304. * }
  1305. * }
  1306. * ```
  1307. *
  1308. * Supports the same querying parameters as {@link QueryMetadata}, except
  1309. * `descendants`. This always queries the whole view.
  1310. *
  1311. * As `shown` is flipped between true and false, items will contain zero of one
  1312. * items.
  1313. *
  1314. * Specifies that a {@link QueryList} should be injected.
  1315. *
  1316. * The injected object is an iterable and observable live list.
  1317. * See {@link QueryList} for more details.
  1318. */
  1319. var ViewQueryMetadata = (function (_super) {
  1320. __extends(ViewQueryMetadata, _super);
  1321. function ViewQueryMetadata(_selector, _a) {
  1322. var _b = _a === void 0 ? {} : _a, _c = _b.descendants, descendants = _c === void 0 ? false : _c, _d = _b.first, first = _d === void 0 ? false : _d;
  1323. _super.call(this, _selector, { descendants: descendants, first: first });
  1324. }
  1325. Object.defineProperty(ViewQueryMetadata.prototype, "isViewQuery", {
  1326. /**
  1327. * always `true` to differentiate it with {@link QueryMetadata}.
  1328. */
  1329. get: function () { return true; },
  1330. enumerable: true,
  1331. configurable: true
  1332. });
  1333. ViewQueryMetadata.prototype.toString = function () { return "@ViewQuery(" + lang_1.stringify(this.selector) + ")"; };
  1334. ViewQueryMetadata = __decorate([
  1335. lang_1.CONST(),
  1336. __metadata('design:paramtypes', [Object, Object])
  1337. ], ViewQueryMetadata);
  1338. return ViewQueryMetadata;
  1339. })(QueryMetadata);
  1340. exports.ViewQueryMetadata = ViewQueryMetadata;
  1341. /**
  1342. * Configures a view query.
  1343. *
  1344. * View queries are set before the `ngAfterViewInit` callback is called.
  1345. *
  1346. * ### Example
  1347. *
  1348. * ```
  1349. * @Component({
  1350. * selector: 'someDir',
  1351. * templateUrl: 'someTemplate',
  1352. * directives: [ItemDirective]
  1353. * })
  1354. * class SomeDir {
  1355. * @ViewChildren(ItemDirective) viewChildren: QueryList<ItemDirective>;
  1356. *
  1357. * ngAfterViewInit() {
  1358. * // viewChildren is set
  1359. * }
  1360. * }
  1361. * ```
  1362. */
  1363. var ViewChildrenMetadata = (function (_super) {
  1364. __extends(ViewChildrenMetadata, _super);
  1365. function ViewChildrenMetadata(_selector) {
  1366. _super.call(this, _selector, { descendants: true });
  1367. }
  1368. ViewChildrenMetadata = __decorate([
  1369. lang_1.CONST(),
  1370. __metadata('design:paramtypes', [Object])
  1371. ], ViewChildrenMetadata);
  1372. return ViewChildrenMetadata;
  1373. })(ViewQueryMetadata);
  1374. exports.ViewChildrenMetadata = ViewChildrenMetadata;
  1375. /**
  1376. * Configures a view query.
  1377. *
  1378. * View queries are set before the `ngAfterViewInit` callback is called.
  1379. *
  1380. * ### Example
  1381. *
  1382. * ```
  1383. * @Component({
  1384. * selector: 'someDir',
  1385. * templateUrl: 'someTemplate',
  1386. * directives: [ItemDirective]
  1387. * })
  1388. * class SomeDir {
  1389. * @ViewChild(ItemDirective) viewChild:ItemDirective;
  1390. *
  1391. * ngAfterViewInit() {
  1392. * // viewChild is set
  1393. * }
  1394. * }
  1395. * ```
  1396. */
  1397. var ViewChildMetadata = (function (_super) {
  1398. __extends(ViewChildMetadata, _super);
  1399. function ViewChildMetadata(_selector) {
  1400. _super.call(this, _selector, { descendants: true, first: true });
  1401. }
  1402. ViewChildMetadata = __decorate([
  1403. lang_1.CONST(),
  1404. __metadata('design:paramtypes', [Object])
  1405. ], ViewChildMetadata);
  1406. return ViewChildMetadata;
  1407. })(ViewQueryMetadata);
  1408. exports.ViewChildMetadata = ViewChildMetadata;
  1409. /***/ },
  1410. /* 5 */
  1411. /***/ function(module, exports) {
  1412. /* WEBPACK VAR INJECTION */(function(global) {var __extends = (this && this.__extends) || function (d, b) {
  1413. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1414. function __() { this.constructor = d; }
  1415. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1416. };
  1417. var globalScope;
  1418. if (typeof window === 'undefined') {
  1419. if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
  1420. // TODO: Replace any with WorkerGlobalScope from lib.webworker.d.ts #3492
  1421. globalScope = self;
  1422. }
  1423. else {
  1424. globalScope = global;
  1425. }
  1426. }
  1427. else {
  1428. globalScope = window;
  1429. }
  1430. ;
  1431. exports.IS_DART = false;
  1432. // Need to declare a new variable for global here since TypeScript
  1433. // exports the original value of the symbol.
  1434. var _global = globalScope;
  1435. exports.global = _global;
  1436. exports.Type = Function;
  1437. function getTypeNameForDebugging(type) {
  1438. return type['name'];
  1439. }
  1440. exports.getTypeNameForDebugging = getTypeNameForDebugging;
  1441. exports.Math = _global.Math;
  1442. exports.Date = _global.Date;
  1443. var _devMode = true;
  1444. var _modeLocked = false;
  1445. function lockMode() {
  1446. _modeLocked = true;
  1447. }
  1448. exports.lockMode = lockMode;
  1449. /**
  1450. * Disable Angular's development mode, which turns off assertions and other
  1451. * checks within the framework.
  1452. *
  1453. * One important assertion this disables verifies that a change detection pass
  1454. * does not result in additional changes to any bindings (also known as
  1455. * unidirectional data flow).
  1456. */
  1457. function enableProdMode() {
  1458. if (_modeLocked) {
  1459. // Cannot use BaseException as that ends up importing from facade/lang.
  1460. throw 'Cannot enable prod mode after platform setup.';
  1461. }
  1462. _devMode = false;
  1463. }
  1464. exports.enableProdMode = enableProdMode;
  1465. function assertionsEnabled() {
  1466. return _devMode;
  1467. }
  1468. exports.assertionsEnabled = assertionsEnabled;
  1469. // TODO: remove calls to assert in production environment
  1470. // Note: Can't just export this and import in in other files
  1471. // as `assert` is a reserved keyword in Dart
  1472. _global.assert = function assert(condition) {
  1473. // TODO: to be fixed properly via #2830, noop for now
  1474. };
  1475. // This function is needed only to properly support Dart's const expressions
  1476. // see https://github.com/angular/ts2dart/pull/151 for more info
  1477. function CONST_EXPR(expr) {
  1478. return expr;
  1479. }
  1480. exports.CONST_EXPR = CONST_EXPR;
  1481. function CONST() {
  1482. return function (target) { return target; };
  1483. }
  1484. exports.CONST = CONST;
  1485. function isPresent(obj) {
  1486. return obj !== undefined && obj !== null;
  1487. }
  1488. exports.isPresent = isPresent;
  1489. function isBlank(obj) {
  1490. return obj === undefined || obj === null;
  1491. }
  1492. exports.isBlank = isBlank;
  1493. function isString(obj) {
  1494. return typeof obj === "string";
  1495. }
  1496. exports.isString = isString;
  1497. function isFunction(obj) {
  1498. return typeof obj === "function";
  1499. }
  1500. exports.isFunction = isFunction;
  1501. function isType(obj) {
  1502. return isFunction(obj);
  1503. }
  1504. exports.isType = isType;
  1505. function isStringMap(obj) {
  1506. return typeof obj === 'object' && obj !== null;
  1507. }
  1508. exports.isStringMap = isStringMap;
  1509. function isPromise(obj) {
  1510. return obj instanceof _global.Promise;
  1511. }
  1512. exports.isPromise = isPromise;
  1513. function isArray(obj) {
  1514. return Array.isArray(obj);
  1515. }
  1516. exports.isArray = isArray;
  1517. function isNumber(obj) {
  1518. return typeof obj === 'number';
  1519. }
  1520. exports.isNumber = isNumber;
  1521. function isDate(obj) {
  1522. return obj instanceof exports.Date && !isNaN(obj.valueOf());
  1523. }
  1524. exports.isDate = isDate;
  1525. function noop() { }
  1526. exports.noop = noop;
  1527. function stringify(token) {
  1528. if (typeof token === 'string') {
  1529. return token;
  1530. }
  1531. if (token === undefined || token === null) {
  1532. return '' + token;
  1533. }
  1534. if (token.name) {
  1535. return token.name;
  1536. }
  1537. var res = token.toString();
  1538. var newLineIndex = res.indexOf("\n");
  1539. return (newLineIndex === -1) ? res : res.substring(0, newLineIndex);
  1540. }
  1541. exports.stringify = stringify;
  1542. // serialize / deserialize enum exist only for consistency with dart API
  1543. // enums in typescript don't need to be serialized
  1544. function serializeEnum(val) {
  1545. return val;
  1546. }
  1547. exports.serializeEnum = serializeEnum;
  1548. function deserializeEnum(val, values) {
  1549. return val;
  1550. }
  1551. exports.deserializeEnum = deserializeEnum;
  1552. var StringWrapper = (function () {
  1553. function StringWrapper() {
  1554. }
  1555. StringWrapper.fromCharCode = function (code) { return String.fromCharCode(code); };
  1556. StringWrapper.charCodeAt = function (s, index) { return s.charCodeAt(index); };
  1557. StringWrapper.split = function (s, regExp) { return s.split(regExp); };
  1558. StringWrapper.equals = function (s, s2) { return s === s2; };
  1559. StringWrapper.stripLeft = function (s, charVal) {
  1560. if (s && s.length) {
  1561. var pos = 0;
  1562. for (var i = 0; i < s.length; i++) {
  1563. if (s[i] != charVal)
  1564. break;
  1565. pos++;
  1566. }
  1567. s = s.substring(pos);
  1568. }
  1569. return s;
  1570. };
  1571. StringWrapper.stripRight = function (s, charVal) {
  1572. if (s && s.length) {
  1573. var pos = s.length;
  1574. for (var i = s.length - 1; i >= 0; i--) {
  1575. if (s[i] != charVal)
  1576. break;
  1577. pos--;
  1578. }
  1579. s = s.substring(0, pos);
  1580. }
  1581. return s;
  1582. };
  1583. StringWrapper.replace = function (s, from, replace) {
  1584. return s.replace(from, replace);
  1585. };
  1586. StringWrapper.replaceAll = function (s, from, replace) {
  1587. return s.replace(from, replace);
  1588. };
  1589. StringWrapper.slice = function (s, from, to) {
  1590. if (from === void 0) { from = 0; }
  1591. if (to === void 0) { to = null; }
  1592. return s.slice(from, to === null ? undefined : to);
  1593. };
  1594. StringWrapper.replaceAllMapped = function (s, from, cb) {
  1595. return s.replace(from, function () {
  1596. var matches = [];
  1597. for (var _i = 0; _i < arguments.length; _i++) {
  1598. matches[_i - 0] = arguments[_i];
  1599. }
  1600. // Remove offset & string from the result array
  1601. matches.splice(-2, 2);
  1602. // The callback receives match, p1, ..., pn
  1603. return cb(matches);
  1604. });
  1605. };
  1606. StringWrapper.contains = function (s, substr) { return s.indexOf(substr) != -1; };
  1607. StringWrapper.compare = function (a, b) {
  1608. if (a < b) {
  1609. return -1;
  1610. }
  1611. else if (a > b) {
  1612. return 1;
  1613. }
  1614. else {
  1615. return 0;
  1616. }
  1617. };
  1618. return StringWrapper;
  1619. })();
  1620. exports.StringWrapper = StringWrapper;
  1621. var StringJoiner = (function () {
  1622. function StringJoiner(parts) {
  1623. if (parts === void 0) { parts = []; }
  1624. this.parts = parts;
  1625. }
  1626. StringJoiner.prototype.add = function (part) { this.parts.push(part); };
  1627. StringJoiner.prototype.toString = function () { return this.parts.join(""); };
  1628. return StringJoiner;
  1629. })();
  1630. exports.StringJoiner = StringJoiner;
  1631. var NumberParseError = (function (_super) {
  1632. __extends(NumberParseError, _super);
  1633. function NumberParseError(message) {
  1634. _super.call(this);
  1635. this.message = message;
  1636. }
  1637. NumberParseError.prototype.toString = function () { return this.message; };
  1638. return NumberParseError;
  1639. })(Error);
  1640. exports.NumberParseError = NumberParseError;
  1641. var NumberWrapper = (function () {
  1642. function NumberWrapper() {
  1643. }
  1644. NumberWrapper.toFixed = function (n, fractionDigits) { return n.toFixed(fractionDigits); };
  1645. NumberWrapper.equal = function (a, b) { return a === b; };
  1646. NumberWrapper.parseIntAutoRadix = function (text) {
  1647. var result = parseInt(text);
  1648. if (isNaN(result)) {
  1649. throw new NumberParseError("Invalid integer literal when parsing " + text);
  1650. }
  1651. return result;
  1652. };
  1653. NumberWrapper.parseInt = function (text, radix) {
  1654. if (radix == 10) {
  1655. if (/^(\-|\+)?[0-9]+$/.test(text)) {
  1656. return parseInt(text, radix);
  1657. }
  1658. }
  1659. else if (radix == 16) {
  1660. if (/^(\-|\+)?[0-9ABCDEFabcdef]+$/.test(text)) {
  1661. return parseInt(text, radix);
  1662. }
  1663. }
  1664. else {
  1665. var result = parseInt(text, radix);
  1666. if (!isNaN(result)) {
  1667. return result;
  1668. }
  1669. }
  1670. throw new NumberParseError("Invalid integer literal when parsing " + text + " in base " +
  1671. radix);
  1672. };
  1673. // TODO: NaN is a valid literal but is returned by parseFloat to indicate an error.
  1674. NumberWrapper.parseFloat = function (text) { return parseFloat(text); };
  1675. Object.defineProperty(NumberWrapper, "NaN", {
  1676. get: function () { return NaN; },
  1677. enumerable: true,
  1678. configurable: true
  1679. });
  1680. NumberWrapper.isNaN = function (value) { return isNaN(value); };
  1681. NumberWrapper.isInteger = function (value) { return Number.isInteger(value); };
  1682. return NumberWrapper;
  1683. })();
  1684. exports.NumberWrapper = NumberWrapper;
  1685. exports.RegExp = _global.RegExp;
  1686. var RegExpWrapper = (function () {
  1687. function RegExpWrapper() {
  1688. }
  1689. RegExpWrapper.create = function (regExpStr, flags) {
  1690. if (flags === void 0) { flags = ''; }
  1691. flags = flags.replace(/g/g, '');
  1692. return new _global.RegExp(regExpStr, flags + 'g');
  1693. };
  1694. RegExpWrapper.firstMatch = function (regExp, input) {
  1695. // Reset multimatch regex state
  1696. regExp.lastIndex = 0;
  1697. return regExp.exec(input);
  1698. };
  1699. RegExpWrapper.test = function (regExp, input) {
  1700. regExp.lastIndex = 0;
  1701. return regExp.test(input);
  1702. };
  1703. RegExpWrapper.matcher = function (regExp, input) {
  1704. // Reset regex state for the case
  1705. // someone did not loop over all matches
  1706. // last time.
  1707. regExp.lastIndex = 0;
  1708. return { re: regExp, input: input };
  1709. };
  1710. return RegExpWrapper;
  1711. })();
  1712. exports.RegExpWrapper = RegExpWrapper;
  1713. var RegExpMatcherWrapper = (function () {
  1714. function RegExpMatcherWrapper() {
  1715. }
  1716. RegExpMatcherWrapper.next = function (matcher) {
  1717. return matcher.re.exec(matcher.input);
  1718. };
  1719. return RegExpMatcherWrapper;
  1720. })();
  1721. exports.RegExpMatcherWrapper = RegExpMatcherWrapper;
  1722. var FunctionWrapper = (function () {
  1723. function FunctionWrapper() {
  1724. }
  1725. FunctionWrapper.apply = function (fn, posArgs) { return fn.apply(null, posArgs); };
  1726. return FunctionWrapper;
  1727. })();
  1728. exports.FunctionWrapper = FunctionWrapper;
  1729. // JS has NaN !== NaN
  1730. function looseIdentical(a, b) {
  1731. return a === b || typeof a === "number" && typeof b === "number" && isNaN(a) && isNaN(b);
  1732. }
  1733. exports.looseIdentical = looseIdentical;
  1734. // JS considers NaN is the same as NaN for map Key (while NaN !== NaN otherwise)
  1735. // see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
  1736. function getMapKey(value) {
  1737. return value;
  1738. }
  1739. exports.getMapKey = getMapKey;
  1740. function normalizeBlank(obj) {
  1741. return isBlank(obj) ? null : obj;
  1742. }
  1743. exports.normalizeBlank = normalizeBlank;
  1744. function normalizeBool(obj) {
  1745. return isBlank(obj) ? false : obj;
  1746. }
  1747. exports.normalizeBool = normalizeBool;
  1748. function isJsObject(o) {
  1749. return o !== null && (typeof o === "function" || typeof o === "object");
  1750. }
  1751. exports.isJsObject = isJsObject;
  1752. function print(obj) {
  1753. console.log(obj);
  1754. }
  1755. exports.print = print;
  1756. // Can't be all uppercase as our transpiler would think it is a special directive...
  1757. var Json = (function () {
  1758. function Json() {
  1759. }
  1760. Json.parse = function (s) { return _global.JSON.parse(s); };
  1761. Json.stringify = function (data) {
  1762. // Dart doesn't take 3 arguments
  1763. return _global.JSON.stringify(data, null, 2);
  1764. };
  1765. return Json;
  1766. })();
  1767. exports.Json = Json;
  1768. var DateWrapper = (function () {
  1769. function DateWrapper() {
  1770. }
  1771. DateWrapper.create = function (year, month, day, hour, minutes, seconds, milliseconds) {
  1772. if (month === void 0) { month = 1; }
  1773. if (day === void 0) { day = 1; }
  1774. if (hour === void 0) { hour = 0; }
  1775. if (minutes === void 0) { minutes = 0; }
  1776. if (seconds === void 0) { seconds = 0; }
  1777. if (milliseconds === void 0) { milliseconds = 0; }
  1778. return new exports.Date(year, month - 1, day, hour, minutes, seconds, milliseconds);
  1779. };
  1780. DateWrapper.fromISOString = function (str) { return new exports.Date(str); };
  1781. DateWrapper.fromMillis = function (ms) { return new exports.Date(ms); };
  1782. DateWrapper.toMillis = function (date) { return date.getTime(); };
  1783. DateWrapper.now = function () { return new exports.Date(); };
  1784. DateWrapper.toJson = function (date) { return date.toJSON(); };
  1785. return DateWrapper;
  1786. })();
  1787. exports.DateWrapper = DateWrapper;
  1788. function setValueOnPath(global, path, value) {
  1789. var parts = path.split('.');
  1790. var obj = global;
  1791. while (parts.length > 1) {
  1792. var name = parts.shift();
  1793. if (obj.hasOwnProperty(name) && isPresent(obj[name])) {
  1794. obj = obj[name];
  1795. }
  1796. else {
  1797. obj = obj[name] = {};
  1798. }
  1799. }
  1800. if (obj === undefined || obj === null) {
  1801. obj = {};
  1802. }
  1803. obj[parts.shift()] = value;
  1804. }
  1805. exports.setValueOnPath = setValueOnPath;
  1806. var _symbolIterator = null;
  1807. function getSymbolIterator() {
  1808. if (isBlank(_symbolIterator)) {
  1809. if (isPresent(Symbol) && isPresent(Symbol.iterator)) {
  1810. _symbolIterator = Symbol.iterator;
  1811. }
  1812. else {
  1813. // es6-shim specific logic
  1814. var keys = Object.getOwnPropertyNames(Map.prototype);
  1815. for (var i = 0; i < keys.length; ++i) {
  1816. var key = keys[i];
  1817. if (key !== 'entries' && key !== 'size' &&
  1818. Map.prototype[key] === Map.prototype['entries']) {
  1819. _symbolIterator = key;
  1820. }
  1821. }
  1822. }
  1823. }
  1824. return _symbolIterator;
  1825. }
  1826. exports.getSymbolIterator = getSymbolIterator;
  1827. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  1828. /***/ },
  1829. /* 6 */
  1830. /***/ function(module, exports, __webpack_require__) {
  1831. /**
  1832. * @module
  1833. * @description
  1834. * The `di` module provides dependency injection container services.
  1835. */
  1836. function __export(m) {
  1837. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1838. }
  1839. var metadata_1 = __webpack_require__(7);
  1840. exports.InjectMetadata = metadata_1.InjectMetadata;
  1841. exports.OptionalMetadata = metadata_1.OptionalMetadata;
  1842. exports.InjectableMetadata = metadata_1.InjectableMetadata;
  1843. exports.SelfMetadata = metadata_1.SelfMetadata;
  1844. exports.HostMetadata = metadata_1.HostMetadata;
  1845. exports.SkipSelfMetadata = metadata_1.SkipSelfMetadata;
  1846. exports.DependencyMetadata = metadata_1.DependencyMetadata;
  1847. // we have to reexport * because Dart and TS export two different sets of types
  1848. __export(__webpack_require__(8));
  1849. var forward_ref_1 = __webpack_require__(10);
  1850. exports.forwardRef = forward_ref_1.forwardRef;
  1851. exports.resolveForwardRef = forward_ref_1.resolveForwardRef;
  1852. var injector_1 = __webpack_require__(11);
  1853. exports.Injector = injector_1.Injector;
  1854. var provider_1 = __webpack_require__(13);
  1855. exports.Binding = provider_1.Binding;
  1856. exports.ProviderBuilder = provider_1.ProviderBuilder;
  1857. exports.ResolvedFactory = provider_1.ResolvedFactory;
  1858. exports.Dependency = provider_1.Dependency;
  1859. exports.bind = provider_1.bind;
  1860. exports.Provider = provider_1.Provider;
  1861. exports.provide = provider_1.provide;
  1862. var key_1 = __webpack_require__(19);
  1863. exports.Key = key_1.Key;
  1864. exports.TypeLiteral = key_1.TypeLiteral;
  1865. var exceptions_1 = __webpack_require__(21);
  1866. exports.NoProviderError = exceptions_1.NoProviderError;
  1867. exports.AbstractProviderError = exceptions_1.AbstractProviderError;
  1868. exports.CyclicDependencyError = exceptions_1.CyclicDependencyError;
  1869. exports.InstantiationError = exceptions_1.InstantiationError;
  1870. exports.InvalidProviderError = exceptions_1.InvalidProviderError;
  1871. exports.NoAnnotationError = exceptions_1.NoAnnotationError;
  1872. exports.OutOfBoundsError = exceptions_1.OutOfBoundsError;
  1873. var opaque_token_1 = __webpack_require__(22);
  1874. exports.OpaqueToken = opaque_token_1.OpaqueToken;
  1875. /***/ },
  1876. /* 7 */
  1877. /***/ function(module, exports, __webpack_require__) {
  1878. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1879. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1880. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1881. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  1882. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1883. };
  1884. var __metadata = (this && this.__metadata) || function (k, v) {
  1885. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  1886. };
  1887. var lang_1 = __webpack_require__(5);
  1888. /**
  1889. * A parameter metadata that specifies a dependency.
  1890. *
  1891. * ### Example ([live demo](http://plnkr.co/edit/6uHYJK?p=preview))
  1892. *
  1893. * ```typescript
  1894. * class Engine {}
  1895. *
  1896. * @Injectable()
  1897. * class Car {
  1898. * engine;
  1899. * constructor(@Inject("MyEngine") engine:Engine) {
  1900. * this.engine = engine;
  1901. * }
  1902. * }
  1903. *
  1904. * var injector = Injector.resolveAndCreate([
  1905. * provide("MyEngine", {useClass: Engine}),
  1906. * Car
  1907. * ]);
  1908. *
  1909. * expect(injector.get(Car).engine instanceof Engine).toBe(true);
  1910. * ```
  1911. *
  1912. * When `@Inject()` is not present, {@link Injector} will use the type annotation of the parameter.
  1913. *
  1914. * ### Example
  1915. *
  1916. * ```typescript
  1917. * class Engine {}
  1918. *
  1919. * @Injectable()
  1920. * class Car {
  1921. * constructor(public engine: Engine) {} //same as constructor(@Inject(Engine) engine:Engine)
  1922. * }
  1923. *
  1924. * var injector = Injector.resolveAndCreate([Engine, Car]);
  1925. * expect(injector.get(Car).engine instanceof Engine).toBe(true);
  1926. * ```
  1927. */
  1928. var InjectMetadata = (function () {
  1929. function InjectMetadata(token) {
  1930. this.token = token;
  1931. }
  1932. InjectMetadata.prototype.toString = function () { return "@Inject(" + lang_1.stringify(this.token) + ")"; };
  1933. InjectMetadata = __decorate([
  1934. lang_1.CONST(),
  1935. __metadata('design:paramtypes', [Object])
  1936. ], InjectMetadata);
  1937. return InjectMetadata;
  1938. })();
  1939. exports.InjectMetadata = InjectMetadata;
  1940. /**
  1941. * A parameter metadata that marks a dependency as optional. {@link Injector} provides `null` if
  1942. * the dependency is not found.
  1943. *
  1944. * ### Example ([live demo](http://plnkr.co/edit/AsryOm?p=preview))
  1945. *
  1946. * ```typescript
  1947. * class Engine {}
  1948. *
  1949. * @Injectable()
  1950. * class Car {
  1951. * engine;
  1952. * constructor(@Optional() engine:Engine) {
  1953. * this.engine = engine;
  1954. * }
  1955. * }
  1956. *
  1957. * var injector = Injector.resolveAndCreate([Car]);
  1958. * expect(injector.get(Car).engine).toBeNull();
  1959. * ```
  1960. */
  1961. var OptionalMetadata = (function () {
  1962. function OptionalMetadata() {
  1963. }
  1964. OptionalMetadata.prototype.toString = function () { return "@Optional()"; };
  1965. OptionalMetadata = __decorate([
  1966. lang_1.CONST(),
  1967. __metadata('design:paramtypes', [])
  1968. ], OptionalMetadata);
  1969. return OptionalMetadata;
  1970. })();
  1971. exports.OptionalMetadata = OptionalMetadata;
  1972. /**
  1973. * `DependencyMetadata` is used by the framework to extend DI.
  1974. * This is internal to Angular and should not be used directly.
  1975. */
  1976. var DependencyMetadata = (function () {
  1977. function DependencyMetadata() {
  1978. }
  1979. Object.defineProperty(DependencyMetadata.prototype, "token", {
  1980. get: function () { return null; },
  1981. enumerable: true,
  1982. configurable: true
  1983. });
  1984. DependencyMetadata = __decorate([
  1985. lang_1.CONST(),
  1986. __metadata('design:paramtypes', [])
  1987. ], DependencyMetadata);
  1988. return DependencyMetadata;
  1989. })();
  1990. exports.DependencyMetadata = DependencyMetadata;
  1991. /**
  1992. * A marker metadata that marks a class as available to {@link Injector} for creation.
  1993. *
  1994. * ### Example ([live demo](http://plnkr.co/edit/Wk4DMQ?p=preview))
  1995. *
  1996. * ```typescript
  1997. * @Injectable()
  1998. * class UsefulService {}
  1999. *
  2000. * @Injectable()
  2001. * class NeedsService {
  2002. * constructor(public service:UsefulService) {}
  2003. * }
  2004. *
  2005. * var injector = Injector.resolveAndCreate([NeedsService, UsefulService]);
  2006. * expect(injector.get(NeedsService).service instanceof UsefulService).toBe(true);
  2007. * ```
  2008. * {@link Injector} will throw {@link NoAnnotationError} when trying to instantiate a class that
  2009. * does not have `@Injectable` marker, as shown in the example below.
  2010. *
  2011. * ```typescript
  2012. * class UsefulService {}
  2013. *
  2014. * class NeedsService {
  2015. * constructor(public service:UsefulService) {}
  2016. * }
  2017. *
  2018. * var injector = Injector.resolveAndCreate([NeedsService, UsefulService]);
  2019. * expect(() => injector.get(NeedsService)).toThrowError();
  2020. * ```
  2021. */
  2022. var InjectableMetadata = (function () {
  2023. function InjectableMetadata() {
  2024. }
  2025. InjectableMetadata = __decorate([
  2026. lang_1.CONST(),
  2027. __metadata('design:paramtypes', [])
  2028. ], InjectableMetadata);
  2029. return InjectableMetadata;
  2030. })();
  2031. exports.InjectableMetadata = InjectableMetadata;
  2032. /**
  2033. * Specifies that an {@link Injector} should retrieve a dependency only from itself.
  2034. *
  2035. * ### Example ([live demo](http://plnkr.co/edit/NeagAg?p=preview))
  2036. *
  2037. * ```typescript
  2038. * class Dependency {
  2039. * }
  2040. *
  2041. * @Injectable()
  2042. * class NeedsDependency {
  2043. * dependency;
  2044. * constructor(@Self() dependency:Dependency) {
  2045. * this.dependency = dependency;
  2046. * }
  2047. * }
  2048. *
  2049. * var inj = Injector.resolveAndCreate([Dependency, NeedsDependency]);
  2050. * var nd = inj.get(NeedsDependency);
  2051. *
  2052. * expect(nd.dependency instanceof Dependency).toBe(true);
  2053. *
  2054. * var inj = Injector.resolveAndCreate([Dependency]);
  2055. * var child = inj.resolveAndCreateChild([NeedsDependency]);
  2056. * expect(() => child.get(NeedsDependency)).toThrowError();
  2057. * ```
  2058. */
  2059. var SelfMetadata = (function () {
  2060. function SelfMetadata() {
  2061. }
  2062. SelfMetadata.prototype.toString = function () { return "@Self()"; };
  2063. SelfMetadata = __decorate([
  2064. lang_1.CONST(),
  2065. __metadata('design:paramtypes', [])
  2066. ], SelfMetadata);
  2067. return SelfMetadata;
  2068. })();
  2069. exports.SelfMetadata = SelfMetadata;
  2070. /**
  2071. * Specifies that the dependency resolution should start from the parent injector.
  2072. *
  2073. * ### Example ([live demo](http://plnkr.co/edit/Wchdzb?p=preview))
  2074. *
  2075. * ```typescript
  2076. * class Dependency {
  2077. * }
  2078. *
  2079. * @Injectable()
  2080. * class NeedsDependency {
  2081. * dependency;
  2082. * constructor(@SkipSelf() dependency:Dependency) {
  2083. * this.dependency = dependency;
  2084. * }
  2085. * }
  2086. *
  2087. * var parent = Injector.resolveAndCreate([Dependency]);
  2088. * var child = parent.resolveAndCreateChild([NeedsDependency]);
  2089. * expect(child.get(NeedsDependency).dependency instanceof Depedency).toBe(true);
  2090. *
  2091. * var inj = Injector.resolveAndCreate([Dependency, NeedsDependency]);
  2092. * expect(() => inj.get(NeedsDependency)).toThrowError();
  2093. * ```
  2094. */
  2095. var SkipSelfMetadata = (function () {
  2096. function SkipSelfMetadata() {
  2097. }
  2098. SkipSelfMetadata.prototype.toString = function () { return "@SkipSelf()"; };
  2099. SkipSelfMetadata = __decorate([
  2100. lang_1.CONST(),
  2101. __metadata('design:paramtypes', [])
  2102. ], SkipSelfMetadata);
  2103. return SkipSelfMetadata;
  2104. })();
  2105. exports.SkipSelfMetadata = SkipSelfMetadata;
  2106. /**
  2107. * Specifies that an injector should retrieve a dependency from any injector until reaching the
  2108. * closest host.
  2109. *
  2110. * In Angular, a component element is automatically declared as a host for all the injectors in
  2111. * its view.
  2112. *
  2113. * ### Example ([live demo](http://plnkr.co/edit/GX79pV?p=preview))
  2114. *
  2115. * In the following example `App` contains `ParentCmp`, which contains `ChildDirective`.
  2116. * So `ParentCmp` is the host of `ChildDirective`.
  2117. *
  2118. * `ChildDirective` depends on two services: `HostService` and `OtherService`.
  2119. * `HostService` is defined at `ParentCmp`, and `OtherService` is defined at `App`.
  2120. *
  2121. *```typescript
  2122. * class OtherService {}
  2123. * class HostService {}
  2124. *
  2125. * @Directive({
  2126. * selector: 'child-directive'
  2127. * })
  2128. * class ChildDirective {
  2129. * constructor(@Optional() @Host() os:OtherService, @Optional() @Host() hs:HostService){
  2130. * console.log("os is null", os);
  2131. * console.log("hs is NOT null", hs);
  2132. * }
  2133. * }
  2134. *
  2135. * @Component({
  2136. * selector: 'parent-cmp',
  2137. * providers: [HostService],
  2138. * template: `
  2139. * Dir: <child-directive></child-directive>
  2140. * `,
  2141. * directives: [ChildDirective]
  2142. * })
  2143. * class ParentCmp {
  2144. * }
  2145. *
  2146. * @Component({
  2147. * selector: 'app',
  2148. * providers: [OtherService],
  2149. * template: `
  2150. * Parent: <parent-cmp></parent-cmp>
  2151. * `,
  2152. * directives: [ParentCmp]
  2153. * })
  2154. * class App {
  2155. * }
  2156. *
  2157. * bootstrap(App);
  2158. *```
  2159. */
  2160. var HostMetadata = (function () {
  2161. function HostMetadata() {
  2162. }
  2163. HostMetadata.prototype.toString = function () { return "@Host()"; };
  2164. HostMetadata = __decorate([
  2165. lang_1.CONST(),
  2166. __metadata('design:paramtypes', [])
  2167. ], HostMetadata);
  2168. return HostMetadata;
  2169. })();
  2170. exports.HostMetadata = HostMetadata;
  2171. /***/ },
  2172. /* 8 */
  2173. /***/ function(module, exports, __webpack_require__) {
  2174. var metadata_1 = __webpack_require__(7);
  2175. var decorators_1 = __webpack_require__(9);
  2176. /**
  2177. * Factory for creating {@link InjectMetadata}.
  2178. */
  2179. exports.Inject = decorators_1.makeParamDecorator(metadata_1.InjectMetadata);
  2180. /**
  2181. * Factory for creating {@link OptionalMetadata}.
  2182. */
  2183. exports.Optional = decorators_1.makeParamDecorator(metadata_1.OptionalMetadata);
  2184. /**
  2185. * Factory for creating {@link InjectableMetadata}.
  2186. */
  2187. exports.Injectable = decorators_1.makeDecorator(metadata_1.InjectableMetadata);
  2188. /**
  2189. * Factory for creating {@link SelfMetadata}.
  2190. */
  2191. exports.Self = decorators_1.makeParamDecorator(metadata_1.SelfMetadata);
  2192. /**
  2193. * Factory for creating {@link HostMetadata}.
  2194. */
  2195. exports.Host = decorators_1.makeParamDecorator(metadata_1.HostMetadata);
  2196. /**
  2197. * Factory for creating {@link SkipSelfMetadata}.
  2198. */
  2199. exports.SkipSelf = decorators_1.makeParamDecorator(metadata_1.SkipSelfMetadata);
  2200. /***/ },
  2201. /* 9 */
  2202. /***/ function(module, exports, __webpack_require__) {
  2203. var lang_1 = __webpack_require__(5);
  2204. function extractAnnotation(annotation) {
  2205. if (lang_1.isFunction(annotation) && annotation.hasOwnProperty('annotation')) {
  2206. // it is a decorator, extract annotation
  2207. annotation = annotation.annotation;
  2208. }
  2209. return annotation;
  2210. }
  2211. function applyParams(fnOrArray, key) {
  2212. if (fnOrArray === Object || fnOrArray === String || fnOrArray === Function ||
  2213. fnOrArray === Number || fnOrArray === Array) {
  2214. throw new Error("Can not use native " + lang_1.stringify(fnOrArray) + " as constructor");
  2215. }
  2216. if (lang_1.isFunction(fnOrArray)) {
  2217. return fnOrArray;
  2218. }
  2219. else if (fnOrArray instanceof Array) {
  2220. var annotations = fnOrArray;
  2221. var fn = fnOrArray[fnOrArray.length - 1];
  2222. if (!lang_1.isFunction(fn)) {
  2223. throw new Error("Last position of Class method array must be Function in key " + key + " was '" + lang_1.stringify(fn) + "'");
  2224. }
  2225. var annoLength = annotations.length - 1;
  2226. if (annoLength != fn.length) {
  2227. throw new Error("Number of annotations (" + annoLength + ") does not match number of arguments (" + fn.length + ") in the function: " + lang_1.stringify(fn));
  2228. }
  2229. var paramsAnnotations = [];
  2230. for (var i = 0, ii = annotations.length - 1; i < ii; i++) {
  2231. var paramAnnotations = [];
  2232. paramsAnnotations.push(paramAnnotations);
  2233. var annotation = annotations[i];
  2234. if (annotation instanceof Array) {
  2235. for (var j = 0; j < annotation.length; j++) {
  2236. paramAnnotations.push(extractAnnotation(annotation[j]));
  2237. }
  2238. }
  2239. else if (lang_1.isFunction(annotation)) {
  2240. paramAnnotations.push(extractAnnotation(annotation));
  2241. }
  2242. else {
  2243. paramAnnotations.push(annotation);
  2244. }
  2245. }
  2246. Reflect.defineMetadata('parameters', paramsAnnotations, fn);
  2247. return fn;
  2248. }
  2249. else {
  2250. throw new Error("Only Function or Array is supported in Class definition for key '" + key + "' is '" + lang_1.stringify(fnOrArray) + "'");
  2251. }
  2252. }
  2253. /**
  2254. * Provides a way for expressing ES6 classes with parameter annotations in ES5.
  2255. *
  2256. * ## Basic Example
  2257. *
  2258. * ```
  2259. * var Greeter = ng.Class({
  2260. * constructor: function(name) {
  2261. * this.name = name;
  2262. * },
  2263. *
  2264. * greet: function() {
  2265. * alert('Hello ' + this.name + '!');
  2266. * }
  2267. * });
  2268. * ```
  2269. *
  2270. * is equivalent to ES6:
  2271. *
  2272. * ```
  2273. * class Greeter {
  2274. * constructor(name) {
  2275. * this.name = name;
  2276. * }
  2277. *
  2278. * greet() {
  2279. * alert('Hello ' + this.name + '!');
  2280. * }
  2281. * }
  2282. * ```
  2283. *
  2284. * or equivalent to ES5:
  2285. *
  2286. * ```
  2287. * var Greeter = function (name) {
  2288. * this.name = name;
  2289. * }
  2290. *
  2291. * Greeter.prototype.greet = function () {
  2292. * alert('Hello ' + this.name + '!');
  2293. * }
  2294. * ```
  2295. *
  2296. * ### Example with parameter annotations
  2297. *
  2298. * ```
  2299. * var MyService = ng.Class({
  2300. * constructor: [String, [new Query(), QueryList], function(name, queryList) {
  2301. * ...
  2302. * }]
  2303. * });
  2304. * ```
  2305. *
  2306. * is equivalent to ES6:
  2307. *
  2308. * ```
  2309. * class MyService {
  2310. * constructor(name: string, @Query() queryList: QueryList) {
  2311. * ...
  2312. * }
  2313. * }
  2314. * ```
  2315. *
  2316. * ### Example with inheritance
  2317. *
  2318. * ```
  2319. * var Shape = ng.Class({
  2320. * constructor: (color) {
  2321. * this.color = color;
  2322. * }
  2323. * });
  2324. *
  2325. * var Square = ng.Class({
  2326. * extends: Shape,
  2327. * constructor: function(color, size) {
  2328. * Shape.call(this, color);
  2329. * this.size = size;
  2330. * }
  2331. * });
  2332. * ```
  2333. */
  2334. function Class(clsDef) {
  2335. var constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor');
  2336. var proto = constructor.prototype;
  2337. if (clsDef.hasOwnProperty('extends')) {
  2338. if (lang_1.isFunction(clsDef.extends)) {
  2339. constructor.prototype = proto =
  2340. Object.create(clsDef.extends.prototype);
  2341. }
  2342. else {
  2343. throw new Error("Class definition 'extends' property must be a constructor function was: " + lang_1.stringify(clsDef.extends));
  2344. }
  2345. }
  2346. for (var key in clsDef) {
  2347. if (key != 'extends' && key != 'prototype' && clsDef.hasOwnProperty(key)) {
  2348. proto[key] = applyParams(clsDef[key], key);
  2349. }
  2350. }
  2351. if (this && this.annotations instanceof Array) {
  2352. Reflect.defineMetadata('annotations', this.annotations, constructor);
  2353. }
  2354. return constructor;
  2355. }
  2356. exports.Class = Class;
  2357. var Reflect = lang_1.global.Reflect;
  2358. if (!(Reflect && Reflect.getMetadata)) {
  2359. throw 'reflect-metadata shim is required when using class decorators';
  2360. }
  2361. function makeDecorator(annotationCls, chainFn) {
  2362. if (chainFn === void 0) { chainFn = null; }
  2363. function DecoratorFactory(objOrType) {
  2364. var annotationInstance = new annotationCls(objOrType);
  2365. if (this instanceof annotationCls) {
  2366. return annotationInstance;
  2367. }
  2368. else {
  2369. var chainAnnotation = lang_1.isFunction(this) && this.annotations instanceof Array ? this.annotations : [];
  2370. chainAnnotation.push(annotationInstance);
  2371. var TypeDecorator = function TypeDecorator(cls) {
  2372. var annotations = Reflect.getOwnMetadata('annotations', cls);
  2373. annotations = annotations || [];
  2374. annotations.push(annotationInstance);
  2375. Reflect.defineMetadata('annotations', annotations, cls);
  2376. return cls;
  2377. };
  2378. TypeDecorator.annotations = chainAnnotation;
  2379. TypeDecorator.Class = Class;
  2380. if (chainFn)
  2381. chainFn(TypeDecorator);
  2382. return TypeDecorator;
  2383. }
  2384. }
  2385. DecoratorFactory.prototype = Object.create(annotationCls.prototype);
  2386. return DecoratorFactory;
  2387. }
  2388. exports.makeDecorator = makeDecorator;
  2389. function makeParamDecorator(annotationCls) {
  2390. function ParamDecoratorFactory() {
  2391. var args = [];
  2392. for (var _i = 0; _i < arguments.length; _i++) {
  2393. args[_i - 0] = arguments[_i];
  2394. }
  2395. var annotationInstance = Object.create(annotationCls.prototype);
  2396. annotationCls.apply(annotationInstance, args);
  2397. if (this instanceof annotationCls) {
  2398. return annotationInstance;
  2399. }
  2400. else {
  2401. ParamDecorator.annotation = annotationInstance;
  2402. return ParamDecorator;
  2403. }
  2404. function ParamDecorator(cls, unusedKey, index) {
  2405. var parameters = Reflect.getMetadata('parameters', cls);
  2406. parameters = parameters || [];
  2407. // there might be gaps if some in between parameters do not have annotations.
  2408. // we pad with nulls.
  2409. while (parameters.length <= index) {
  2410. parameters.push(null);
  2411. }
  2412. parameters[index] = parameters[index] || [];
  2413. var annotationsForParam = parameters[index];
  2414. annotationsForParam.push(annotationInstance);
  2415. Reflect.defineMetadata('parameters', parameters, cls);
  2416. return cls;
  2417. }
  2418. }
  2419. ParamDecoratorFactory.prototype = Object.create(annotationCls.prototype);
  2420. return ParamDecoratorFactory;
  2421. }
  2422. exports.makeParamDecorator = makeParamDecorator;
  2423. function makePropDecorator(decoratorCls) {
  2424. function PropDecoratorFactory() {
  2425. var args = [];
  2426. for (var _i = 0; _i < arguments.length; _i++) {
  2427. args[_i - 0] = arguments[_i];
  2428. }
  2429. var decoratorInstance = Object.create(decoratorCls.prototype);
  2430. decoratorCls.apply(decoratorInstance, args);
  2431. if (this instanceof decoratorCls) {
  2432. return decoratorInstance;
  2433. }
  2434. else {
  2435. return function PropDecorator(target, name) {
  2436. var meta = Reflect.getOwnMetadata('propMetadata', target.constructor);
  2437. meta = meta || {};
  2438. meta[name] = meta[name] || [];
  2439. meta[name].unshift(decoratorInstance);
  2440. Reflect.defineMetadata('propMetadata', meta, target.constructor);
  2441. };
  2442. }
  2443. }
  2444. PropDecoratorFactory.prototype = Object.create(decoratorCls.prototype);
  2445. return PropDecoratorFactory;
  2446. }
  2447. exports.makePropDecorator = makePropDecorator;
  2448. /***/ },
  2449. /* 10 */
  2450. /***/ function(module, exports, __webpack_require__) {
  2451. var lang_1 = __webpack_require__(5);
  2452. /**
  2453. * Allows to refer to references which are not yet defined.
  2454. *
  2455. * For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
  2456. * DI is declared,
  2457. * but not yet defined. It is also used when the `token` which we use when creating a query is not
  2458. * yet defined.
  2459. *
  2460. * ### Example
  2461. * {@example core/di/ts/forward_ref/forward_ref.ts region='forward_ref'}
  2462. */
  2463. function forwardRef(forwardRefFn) {
  2464. forwardRefFn.__forward_ref__ = forwardRef;
  2465. forwardRefFn.toString = function () { return lang_1.stringify(this()); };
  2466. return forwardRefFn;
  2467. }
  2468. exports.forwardRef = forwardRef;
  2469. /**
  2470. * Lazily retrieves the reference value from a forwardRef.
  2471. *
  2472. * Acts as the identity function when given a non-forward-ref value.
  2473. *
  2474. * ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview))
  2475. *
  2476. * ```typescript
  2477. * var ref = forwardRef(() => "refValue");
  2478. * expect(resolveForwardRef(ref)).toEqual("refValue");
  2479. * expect(resolveForwardRef("regularValue")).toEqual("regularValue");
  2480. * ```
  2481. *
  2482. * See: {@link forwardRef}
  2483. */
  2484. function resolveForwardRef(type) {
  2485. if (lang_1.isFunction(type) && type.hasOwnProperty('__forward_ref__') &&
  2486. type.__forward_ref__ === forwardRef) {
  2487. return type();
  2488. }
  2489. else {
  2490. return type;
  2491. }
  2492. }
  2493. exports.resolveForwardRef = resolveForwardRef;
  2494. /***/ },
  2495. /* 11 */
  2496. /***/ function(module, exports, __webpack_require__) {
  2497. var collection_1 = __webpack_require__(12);
  2498. var provider_1 = __webpack_require__(13);
  2499. var exceptions_1 = __webpack_require__(21);
  2500. var lang_1 = __webpack_require__(5);
  2501. var key_1 = __webpack_require__(19);
  2502. var metadata_1 = __webpack_require__(7);
  2503. // Threshold for the dynamic version
  2504. var _MAX_CONSTRUCTION_COUNTER = 10;
  2505. exports.UNDEFINED = lang_1.CONST_EXPR(new Object());
  2506. /**
  2507. * Visibility of a {@link Provider}.
  2508. */
  2509. (function (Visibility) {
  2510. /**
  2511. * A `Public` {@link Provider} is only visible to regular (as opposed to host) child injectors.
  2512. */
  2513. Visibility[Visibility["Public"] = 0] = "Public";
  2514. /**
  2515. * A `Private` {@link Provider} is only visible to host (as opposed to regular) child injectors.
  2516. */
  2517. Visibility[Visibility["Private"] = 1] = "Private";
  2518. /**
  2519. * A `PublicAndPrivate` {@link Provider} is visible to both host and regular child injectors.
  2520. */
  2521. Visibility[Visibility["PublicAndPrivate"] = 2] = "PublicAndPrivate";
  2522. })(exports.Visibility || (exports.Visibility = {}));
  2523. var Visibility = exports.Visibility;
  2524. function canSee(src, dst) {
  2525. return (src === dst) ||
  2526. (dst === Visibility.PublicAndPrivate || src === Visibility.PublicAndPrivate);
  2527. }
  2528. var ProtoInjectorInlineStrategy = (function () {
  2529. function ProtoInjectorInlineStrategy(protoEI, bwv) {
  2530. this.provider0 = null;
  2531. this.provider1 = null;
  2532. this.provider2 = null;
  2533. this.provider3 = null;
  2534. this.provider4 = null;
  2535. this.provider5 = null;
  2536. this.provider6 = null;
  2537. this.provider7 = null;
  2538. this.provider8 = null;
  2539. this.provider9 = null;
  2540. this.keyId0 = null;
  2541. this.keyId1 = null;
  2542. this.keyId2 = null;
  2543. this.keyId3 = null;
  2544. this.keyId4 = null;
  2545. this.keyId5 = null;
  2546. this.keyId6 = null;
  2547. this.keyId7 = null;
  2548. this.keyId8 = null;
  2549. this.keyId9 = null;
  2550. this.visibility0 = null;
  2551. this.visibility1 = null;
  2552. this.visibility2 = null;
  2553. this.visibility3 = null;
  2554. this.visibility4 = null;
  2555. this.visibility5 = null;
  2556. this.visibility6 = null;
  2557. this.visibility7 = null;
  2558. this.visibility8 = null;
  2559. this.visibility9 = null;
  2560. var length = bwv.length;
  2561. if (length > 0) {
  2562. this.provider0 = bwv[0].provider;
  2563. this.keyId0 = bwv[0].getKeyId();
  2564. this.visibility0 = bwv[0].visibility;
  2565. }
  2566. if (length > 1) {
  2567. this.provider1 = bwv[1].provider;
  2568. this.keyId1 = bwv[1].getKeyId();
  2569. this.visibility1 = bwv[1].visibility;
  2570. }
  2571. if (length > 2) {
  2572. this.provider2 = bwv[2].provider;
  2573. this.keyId2 = bwv[2].getKeyId();
  2574. this.visibility2 = bwv[2].visibility;
  2575. }
  2576. if (length > 3) {
  2577. this.provider3 = bwv[3].provider;
  2578. this.keyId3 = bwv[3].getKeyId();
  2579. this.visibility3 = bwv[3].visibility;
  2580. }
  2581. if (length > 4) {
  2582. this.provider4 = bwv[4].provider;
  2583. this.keyId4 = bwv[4].getKeyId();
  2584. this.visibility4 = bwv[4].visibility;
  2585. }
  2586. if (length > 5) {
  2587. this.provider5 = bwv[5].provider;
  2588. this.keyId5 = bwv[5].getKeyId();
  2589. this.visibility5 = bwv[5].visibility;
  2590. }
  2591. if (length > 6) {
  2592. this.provider6 = bwv[6].provider;
  2593. this.keyId6 = bwv[6].getKeyId();
  2594. this.visibility6 = bwv[6].visibility;
  2595. }
  2596. if (length > 7) {
  2597. this.provider7 = bwv[7].provider;
  2598. this.keyId7 = bwv[7].getKeyId();
  2599. this.visibility7 = bwv[7].visibility;
  2600. }
  2601. if (length > 8) {
  2602. this.provider8 = bwv[8].provider;
  2603. this.keyId8 = bwv[8].getKeyId();
  2604. this.visibility8 = bwv[8].visibility;
  2605. }
  2606. if (length > 9) {
  2607. this.provider9 = bwv[9].provider;
  2608. this.keyId9 = bwv[9].getKeyId();
  2609. this.visibility9 = bwv[9].visibility;
  2610. }
  2611. }
  2612. ProtoInjectorInlineStrategy.prototype.getProviderAtIndex = function (index) {
  2613. if (index == 0)
  2614. return this.provider0;
  2615. if (index == 1)
  2616. return this.provider1;
  2617. if (index == 2)
  2618. return this.provider2;
  2619. if (index == 3)
  2620. return this.provider3;
  2621. if (index == 4)
  2622. return this.provider4;
  2623. if (index == 5)
  2624. return this.provider5;
  2625. if (index == 6)
  2626. return this.provider6;
  2627. if (index == 7)
  2628. return this.provider7;
  2629. if (index == 8)
  2630. return this.provider8;
  2631. if (index == 9)
  2632. return this.provider9;
  2633. throw new exceptions_1.OutOfBoundsError(index);
  2634. };
  2635. ProtoInjectorInlineStrategy.prototype.createInjectorStrategy = function (injector) {
  2636. return new InjectorInlineStrategy(injector, this);
  2637. };
  2638. return ProtoInjectorInlineStrategy;
  2639. })();
  2640. exports.ProtoInjectorInlineStrategy = ProtoInjectorInlineStrategy;
  2641. var ProtoInjectorDynamicStrategy = (function () {
  2642. function ProtoInjectorDynamicStrategy(protoInj, bwv) {
  2643. var len = bwv.length;
  2644. this.providers = collection_1.ListWrapper.createFixedSize(len);
  2645. this.keyIds = collection_1.ListWrapper.createFixedSize(len);
  2646. this.visibilities = collection_1.ListWrapper.createFixedSize(len);
  2647. for (var i = 0; i < len; i++) {
  2648. this.providers[i] = bwv[i].provider;
  2649. this.keyIds[i] = bwv[i].getKeyId();
  2650. this.visibilities[i] = bwv[i].visibility;
  2651. }
  2652. }
  2653. ProtoInjectorDynamicStrategy.prototype.getProviderAtIndex = function (index) {
  2654. if (index < 0 || index >= this.providers.length) {
  2655. throw new exceptions_1.OutOfBoundsError(index);
  2656. }
  2657. return this.providers[index];
  2658. };
  2659. ProtoInjectorDynamicStrategy.prototype.createInjectorStrategy = function (ei) {
  2660. return new InjectorDynamicStrategy(this, ei);
  2661. };
  2662. return ProtoInjectorDynamicStrategy;
  2663. })();
  2664. exports.ProtoInjectorDynamicStrategy = ProtoInjectorDynamicStrategy;
  2665. var ProtoInjector = (function () {
  2666. function ProtoInjector(bwv) {
  2667. this.numberOfProviders = bwv.length;
  2668. this._strategy = bwv.length > _MAX_CONSTRUCTION_COUNTER ?
  2669. new ProtoInjectorDynamicStrategy(this, bwv) :
  2670. new ProtoInjectorInlineStrategy(this, bwv);
  2671. }
  2672. ProtoInjector.prototype.getProviderAtIndex = function (index) { return this._strategy.getProviderAtIndex(index); };
  2673. return ProtoInjector;
  2674. })();
  2675. exports.ProtoInjector = ProtoInjector;
  2676. var InjectorInlineStrategy = (function () {
  2677. function InjectorInlineStrategy(injector, protoStrategy) {
  2678. this.injector = injector;
  2679. this.protoStrategy = protoStrategy;
  2680. this.obj0 = exports.UNDEFINED;
  2681. this.obj1 = exports.UNDEFINED;
  2682. this.obj2 = exports.UNDEFINED;
  2683. this.obj3 = exports.UNDEFINED;
  2684. this.obj4 = exports.UNDEFINED;
  2685. this.obj5 = exports.UNDEFINED;
  2686. this.obj6 = exports.UNDEFINED;
  2687. this.obj7 = exports.UNDEFINED;
  2688. this.obj8 = exports.UNDEFINED;
  2689. this.obj9 = exports.UNDEFINED;
  2690. }
  2691. InjectorInlineStrategy.prototype.resetConstructionCounter = function () { this.injector._constructionCounter = 0; };
  2692. InjectorInlineStrategy.prototype.instantiateProvider = function (provider, visibility) {
  2693. return this.injector._new(provider, visibility);
  2694. };
  2695. InjectorInlineStrategy.prototype.attach = function (parent, isHost) {
  2696. var inj = this.injector;
  2697. inj._parent = parent;
  2698. inj._isHost = isHost;
  2699. };
  2700. InjectorInlineStrategy.prototype.getObjByKeyId = function (keyId, visibility) {
  2701. var p = this.protoStrategy;
  2702. var inj = this.injector;
  2703. if (p.keyId0 === keyId && canSee(p.visibility0, visibility)) {
  2704. if (this.obj0 === exports.UNDEFINED) {
  2705. this.obj0 = inj._new(p.provider0, p.visibility0);
  2706. }
  2707. return this.obj0;
  2708. }
  2709. if (p.keyId1 === keyId && canSee(p.visibility1, visibility)) {
  2710. if (this.obj1 === exports.UNDEFINED) {
  2711. this.obj1 = inj._new(p.provider1, p.visibility1);
  2712. }
  2713. return this.obj1;
  2714. }
  2715. if (p.keyId2 === keyId && canSee(p.visibility2, visibility)) {
  2716. if (this.obj2 === exports.UNDEFINED) {
  2717. this.obj2 = inj._new(p.provider2, p.visibility2);
  2718. }
  2719. return this.obj2;
  2720. }
  2721. if (p.keyId3 === keyId && canSee(p.visibility3, visibility)) {
  2722. if (this.obj3 === exports.UNDEFINED) {
  2723. this.obj3 = inj._new(p.provider3, p.visibility3);
  2724. }
  2725. return this.obj3;
  2726. }
  2727. if (p.keyId4 === keyId && canSee(p.visibility4, visibility)) {
  2728. if (this.obj4 === exports.UNDEFINED) {
  2729. this.obj4 = inj._new(p.provider4, p.visibility4);
  2730. }
  2731. return this.obj4;
  2732. }
  2733. if (p.keyId5 === keyId && canSee(p.visibility5, visibility)) {
  2734. if (this.obj5 === exports.UNDEFINED) {
  2735. this.obj5 = inj._new(p.provider5, p.visibility5);
  2736. }
  2737. return this.obj5;
  2738. }
  2739. if (p.keyId6 === keyId && canSee(p.visibility6, visibility)) {
  2740. if (this.obj6 === exports.UNDEFINED) {
  2741. this.obj6 = inj._new(p.provider6, p.visibility6);
  2742. }
  2743. return this.obj6;
  2744. }
  2745. if (p.keyId7 === keyId && canSee(p.visibility7, visibility)) {
  2746. if (this.obj7 === exports.UNDEFINED) {
  2747. this.obj7 = inj._new(p.provider7, p.visibility7);
  2748. }
  2749. return this.obj7;
  2750. }
  2751. if (p.keyId8 === keyId && canSee(p.visibility8, visibility)) {
  2752. if (this.obj8 === exports.UNDEFINED) {
  2753. this.obj8 = inj._new(p.provider8, p.visibility8);
  2754. }
  2755. return this.obj8;
  2756. }
  2757. if (p.keyId9 === keyId && canSee(p.visibility9, visibility)) {
  2758. if (this.obj9 === exports.UNDEFINED) {
  2759. this.obj9 = inj._new(p.provider9, p.visibility9);
  2760. }
  2761. return this.obj9;
  2762. }
  2763. return exports.UNDEFINED;
  2764. };
  2765. InjectorInlineStrategy.prototype.getObjAtIndex = function (index) {
  2766. if (index == 0)
  2767. return this.obj0;
  2768. if (index == 1)
  2769. return this.obj1;
  2770. if (index == 2)
  2771. return this.obj2;
  2772. if (index == 3)
  2773. return this.obj3;
  2774. if (index == 4)
  2775. return this.obj4;
  2776. if (index == 5)
  2777. return this.obj5;
  2778. if (index == 6)
  2779. return this.obj6;
  2780. if (index == 7)
  2781. return this.obj7;
  2782. if (index == 8)
  2783. return this.obj8;
  2784. if (index == 9)
  2785. return this.obj9;
  2786. throw new exceptions_1.OutOfBoundsError(index);
  2787. };
  2788. InjectorInlineStrategy.prototype.getMaxNumberOfObjects = function () { return _MAX_CONSTRUCTION_COUNTER; };
  2789. return InjectorInlineStrategy;
  2790. })();
  2791. exports.InjectorInlineStrategy = InjectorInlineStrategy;
  2792. var InjectorDynamicStrategy = (function () {
  2793. function InjectorDynamicStrategy(protoStrategy, injector) {
  2794. this.protoStrategy = protoStrategy;
  2795. this.injector = injector;
  2796. this.objs = collection_1.ListWrapper.createFixedSize(protoStrategy.providers.length);
  2797. collection_1.ListWrapper.fill(this.objs, exports.UNDEFINED);
  2798. }
  2799. InjectorDynamicStrategy.prototype.resetConstructionCounter = function () { this.injector._constructionCounter = 0; };
  2800. InjectorDynamicStrategy.prototype.instantiateProvider = function (provider, visibility) {
  2801. return this.injector._new(provider, visibility);
  2802. };
  2803. InjectorDynamicStrategy.prototype.attach = function (parent, isHost) {
  2804. var inj = this.injector;
  2805. inj._parent = parent;
  2806. inj._isHost = isHost;
  2807. };
  2808. InjectorDynamicStrategy.prototype.getObjByKeyId = function (keyId, visibility) {
  2809. var p = this.protoStrategy;
  2810. for (var i = 0; i < p.keyIds.length; i++) {
  2811. if (p.keyIds[i] === keyId && canSee(p.visibilities[i], visibility)) {
  2812. if (this.objs[i] === exports.UNDEFINED) {
  2813. this.objs[i] = this.injector._new(p.providers[i], p.visibilities[i]);
  2814. }
  2815. return this.objs[i];
  2816. }
  2817. }
  2818. return exports.UNDEFINED;
  2819. };
  2820. InjectorDynamicStrategy.prototype.getObjAtIndex = function (index) {
  2821. if (index < 0 || index >= this.objs.length) {
  2822. throw new exceptions_1.OutOfBoundsError(index);
  2823. }
  2824. return this.objs[index];
  2825. };
  2826. InjectorDynamicStrategy.prototype.getMaxNumberOfObjects = function () { return this.objs.length; };
  2827. return InjectorDynamicStrategy;
  2828. })();
  2829. exports.InjectorDynamicStrategy = InjectorDynamicStrategy;
  2830. var ProviderWithVisibility = (function () {
  2831. function ProviderWithVisibility(provider, visibility) {
  2832. this.provider = provider;
  2833. this.visibility = visibility;
  2834. }
  2835. ;
  2836. ProviderWithVisibility.prototype.getKeyId = function () { return this.provider.key.id; };
  2837. return ProviderWithVisibility;
  2838. })();
  2839. exports.ProviderWithVisibility = ProviderWithVisibility;
  2840. /**
  2841. * A dependency injection container used for instantiating objects and resolving dependencies.
  2842. *
  2843. * An `Injector` is a replacement for a `new` operator, which can automatically resolve the
  2844. * constructor dependencies.
  2845. *
  2846. * In typical use, application code asks for the dependencies in the constructor and they are
  2847. * resolved by the `Injector`.
  2848. *
  2849. * ### Example ([live demo](http://plnkr.co/edit/jzjec0?p=preview))
  2850. *
  2851. * The following example creates an `Injector` configured to create `Engine` and `Car`.
  2852. *
  2853. * ```typescript
  2854. * @Injectable()
  2855. * class Engine {
  2856. * }
  2857. *
  2858. * @Injectable()
  2859. * class Car {
  2860. * constructor(public engine:Engine) {}
  2861. * }
  2862. *
  2863. * var injector = Injector.resolveAndCreate([Car, Engine]);
  2864. * var car = injector.get(Car);
  2865. * expect(car instanceof Car).toBe(true);
  2866. * expect(car.engine instanceof Engine).toBe(true);
  2867. * ```
  2868. *
  2869. * Notice, we don't use the `new` operator because we explicitly want to have the `Injector`
  2870. * resolve all of the object's dependencies automatically.
  2871. */
  2872. var Injector = (function () {
  2873. /**
  2874. * Private
  2875. */
  2876. function Injector(_proto /* ProtoInjector */, _parent, _depProvider, _debugContext) {
  2877. if (_parent === void 0) { _parent = null; }
  2878. if (_depProvider === void 0) { _depProvider = null; }
  2879. if (_debugContext === void 0) { _debugContext = null; }
  2880. this._depProvider = _depProvider;
  2881. this._debugContext = _debugContext;
  2882. /** @internal */
  2883. this._isHost = false;
  2884. /** @internal */
  2885. this._constructionCounter = 0;
  2886. this._proto = _proto;
  2887. this._parent = _parent;
  2888. this._strategy = _proto._strategy.createInjectorStrategy(this);
  2889. }
  2890. /**
  2891. * Turns an array of provider definitions into an array of resolved providers.
  2892. *
  2893. * A resolution is a process of flattening multiple nested arrays and converting individual
  2894. * providers into an array of {@link ResolvedProvider}s.
  2895. *
  2896. * ### Example ([live demo](http://plnkr.co/edit/AiXTHi?p=preview))
  2897. *
  2898. * ```typescript
  2899. * @Injectable()
  2900. * class Engine {
  2901. * }
  2902. *
  2903. * @Injectable()
  2904. * class Car {
  2905. * constructor(public engine:Engine) {}
  2906. * }
  2907. *
  2908. * var providers = Injector.resolve([Car, [[Engine]]]);
  2909. *
  2910. * expect(providers.length).toEqual(2);
  2911. *
  2912. * expect(providers[0] instanceof ResolvedProvider).toBe(true);
  2913. * expect(providers[0].key.displayName).toBe("Car");
  2914. * expect(providers[0].dependencies.length).toEqual(1);
  2915. * expect(providers[0].factory).toBeDefined();
  2916. *
  2917. * expect(providers[1].key.displayName).toBe("Engine");
  2918. * });
  2919. * ```
  2920. *
  2921. * See {@link Injector#fromResolvedProviders} for more info.
  2922. */
  2923. Injector.resolve = function (providers) {
  2924. return provider_1.resolveProviders(providers);
  2925. };
  2926. /**
  2927. * Resolves an array of providers and creates an injector from those providers.
  2928. *
  2929. * The passed-in providers can be an array of `Type`, {@link Provider},
  2930. * or a recursive array of more providers.
  2931. *
  2932. * ### Example ([live demo](http://plnkr.co/edit/ePOccA?p=preview))
  2933. *
  2934. * ```typescript
  2935. * @Injectable()
  2936. * class Engine {
  2937. * }
  2938. *
  2939. * @Injectable()
  2940. * class Car {
  2941. * constructor(public engine:Engine) {}
  2942. * }
  2943. *
  2944. * var injector = Injector.resolveAndCreate([Car, Engine]);
  2945. * expect(injector.get(Car) instanceof Car).toBe(true);
  2946. * ```
  2947. *
  2948. * This function is slower than the corresponding `fromResolvedProviders`
  2949. * because it needs to resolve the passed-in providers first.
  2950. * See {@link Injector#resolve} and {@link Injector#fromResolvedProviders}.
  2951. */
  2952. Injector.resolveAndCreate = function (providers) {
  2953. var resolvedProviders = Injector.resolve(providers);
  2954. return Injector.fromResolvedProviders(resolvedProviders);
  2955. };
  2956. /**
  2957. * Creates an injector from previously resolved providers.
  2958. *
  2959. * This API is the recommended way to construct injectors in performance-sensitive parts.
  2960. *
  2961. * ### Example ([live demo](http://plnkr.co/edit/KrSMci?p=preview))
  2962. *
  2963. * ```typescript
  2964. * @Injectable()
  2965. * class Engine {
  2966. * }
  2967. *
  2968. * @Injectable()
  2969. * class Car {
  2970. * constructor(public engine:Engine) {}
  2971. * }
  2972. *
  2973. * var providers = Injector.resolve([Car, Engine]);
  2974. * var injector = Injector.fromResolvedProviders(providers);
  2975. * expect(injector.get(Car) instanceof Car).toBe(true);
  2976. * ```
  2977. */
  2978. Injector.fromResolvedProviders = function (providers) {
  2979. var bd = providers.map(function (b) { return new ProviderWithVisibility(b, Visibility.Public); });
  2980. var proto = new ProtoInjector(bd);
  2981. return new Injector(proto, null, null);
  2982. };
  2983. /**
  2984. * @deprecated
  2985. */
  2986. Injector.fromResolvedBindings = function (providers) {
  2987. return Injector.fromResolvedProviders(providers);
  2988. };
  2989. /**
  2990. * @internal
  2991. */
  2992. Injector.prototype.debugContext = function () { return this._debugContext(); };
  2993. /**
  2994. * Retrieves an instance from the injector based on the provided token.
  2995. * Throws {@link NoProviderError} if not found.
  2996. *
  2997. * ### Example ([live demo](http://plnkr.co/edit/HeXSHg?p=preview))
  2998. *
  2999. * ```typescript
  3000. * var injector = Injector.resolveAndCreate([
  3001. * provide("validToken", {useValue: "Value"})
  3002. * ]);
  3003. * expect(injector.get("validToken")).toEqual("Value");
  3004. * expect(() => injector.get("invalidToken")).toThrowError();
  3005. * ```
  3006. *
  3007. * `Injector` returns itself when given `Injector` as a token.
  3008. *
  3009. * ```typescript
  3010. * var injector = Injector.resolveAndCreate([]);
  3011. * expect(injector.get(Injector)).toBe(injector);
  3012. * ```
  3013. */
  3014. Injector.prototype.get = function (token) {
  3015. return this._getByKey(key_1.Key.get(token), null, null, false, Visibility.PublicAndPrivate);
  3016. };
  3017. /**
  3018. * Retrieves an instance from the injector based on the provided token.
  3019. * Returns null if not found.
  3020. *
  3021. * ### Example ([live demo](http://plnkr.co/edit/tpEbEy?p=preview))
  3022. *
  3023. * ```typescript
  3024. * var injector = Injector.resolveAndCreate([
  3025. * provide("validToken", {useValue: "Value"})
  3026. * ]);
  3027. * expect(injector.getOptional("validToken")).toEqual("Value");
  3028. * expect(injector.getOptional("invalidToken")).toBe(null);
  3029. * ```
  3030. *
  3031. * `Injector` returns itself when given `Injector` as a token.
  3032. *
  3033. * ```typescript
  3034. * var injector = Injector.resolveAndCreate([]);
  3035. * expect(injector.getOptional(Injector)).toBe(injector);
  3036. * ```
  3037. */
  3038. Injector.prototype.getOptional = function (token) {
  3039. return this._getByKey(key_1.Key.get(token), null, null, true, Visibility.PublicAndPrivate);
  3040. };
  3041. /**
  3042. * @internal
  3043. */
  3044. Injector.prototype.getAt = function (index) { return this._strategy.getObjAtIndex(index); };
  3045. Object.defineProperty(Injector.prototype, "parent", {
  3046. /**
  3047. * Parent of this injector.
  3048. *
  3049. * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
  3050. * -->
  3051. *
  3052. * ### Example ([live demo](http://plnkr.co/edit/eosMGo?p=preview))
  3053. *
  3054. * ```typescript
  3055. * var parent = Injector.resolveAndCreate([]);
  3056. * var child = parent.resolveAndCreateChild([]);
  3057. * expect(child.parent).toBe(parent);
  3058. * ```
  3059. */
  3060. get: function () { return this._parent; },
  3061. enumerable: true,
  3062. configurable: true
  3063. });
  3064. Object.defineProperty(Injector.prototype, "internalStrategy", {
  3065. /**
  3066. * @internal
  3067. * Internal. Do not use.
  3068. * We return `any` not to export the InjectorStrategy type.
  3069. */
  3070. get: function () { return this._strategy; },
  3071. enumerable: true,
  3072. configurable: true
  3073. });
  3074. /**
  3075. * Resolves an array of providers and creates a child injector from those providers.
  3076. *
  3077. * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
  3078. * -->
  3079. *
  3080. * The passed-in providers can be an array of `Type`, {@link Provider},
  3081. * or a recursive array of more providers.
  3082. *
  3083. * ### Example ([live demo](http://plnkr.co/edit/opB3T4?p=preview))
  3084. *
  3085. * ```typescript
  3086. * class ParentProvider {}
  3087. * class ChildProvider {}
  3088. *
  3089. * var parent = Injector.resolveAndCreate([ParentProvider]);
  3090. * var child = parent.resolveAndCreateChild([ChildProvider]);
  3091. *
  3092. * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
  3093. * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
  3094. * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
  3095. * ```
  3096. *
  3097. * This function is slower than the corresponding `createChildFromResolved`
  3098. * because it needs to resolve the passed-in providers first.
  3099. * See {@link Injector#resolve} and {@link Injector#createChildFromResolved}.
  3100. */
  3101. Injector.prototype.resolveAndCreateChild = function (providers) {
  3102. var resolvedProviders = Injector.resolve(providers);
  3103. return this.createChildFromResolved(resolvedProviders);
  3104. };
  3105. /**
  3106. * Creates a child injector from previously resolved providers.
  3107. *
  3108. * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
  3109. * -->
  3110. *
  3111. * This API is the recommended way to construct injectors in performance-sensitive parts.
  3112. *
  3113. * ### Example ([live demo](http://plnkr.co/edit/VhyfjN?p=preview))
  3114. *
  3115. * ```typescript
  3116. * class ParentProvider {}
  3117. * class ChildProvider {}
  3118. *
  3119. * var parentProviders = Injector.resolve([ParentProvider]);
  3120. * var childProviders = Injector.resolve([ChildProvider]);
  3121. *
  3122. * var parent = Injector.fromResolvedProviders(parentProviders);
  3123. * var child = parent.createChildFromResolved(childProviders);
  3124. *
  3125. * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
  3126. * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
  3127. * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
  3128. * ```
  3129. */
  3130. Injector.prototype.createChildFromResolved = function (providers) {
  3131. var bd = providers.map(function (b) { return new ProviderWithVisibility(b, Visibility.Public); });
  3132. var proto = new ProtoInjector(bd);
  3133. var inj = new Injector(proto, null, null);
  3134. inj._parent = this;
  3135. return inj;
  3136. };
  3137. /**
  3138. * Resolves a provider and instantiates an object in the context of the injector.
  3139. *
  3140. * The created object does not get cached by the injector.
  3141. *
  3142. * ### Example ([live demo](http://plnkr.co/edit/yvVXoB?p=preview))
  3143. *
  3144. * ```typescript
  3145. * @Injectable()
  3146. * class Engine {
  3147. * }
  3148. *
  3149. * @Injectable()
  3150. * class Car {
  3151. * constructor(public engine:Engine) {}
  3152. * }
  3153. *
  3154. * var injector = Injector.resolveAndCreate([Engine]);
  3155. *
  3156. * var car = injector.resolveAndInstantiate(Car);
  3157. * expect(car.engine).toBe(injector.get(Engine));
  3158. * expect(car).not.toBe(injector.resolveAndInstantiate(Car));
  3159. * ```
  3160. */
  3161. Injector.prototype.resolveAndInstantiate = function (provider) {
  3162. return this.instantiateResolved(Injector.resolve([provider])[0]);
  3163. };
  3164. /**
  3165. * Instantiates an object using a resolved provider in the context of the injector.
  3166. *
  3167. * The created object does not get cached by the injector.
  3168. *
  3169. * ### Example ([live demo](http://plnkr.co/edit/ptCImQ?p=preview))
  3170. *
  3171. * ```typescript
  3172. * @Injectable()
  3173. * class Engine {
  3174. * }
  3175. *
  3176. * @Injectable()
  3177. * class Car {
  3178. * constructor(public engine:Engine) {}
  3179. * }
  3180. *
  3181. * var injector = Injector.resolveAndCreate([Engine]);
  3182. * var carProvider = Injector.resolve([Car])[0];
  3183. * var car = injector.instantiateResolved(carProvider);
  3184. * expect(car.engine).toBe(injector.get(Engine));
  3185. * expect(car).not.toBe(injector.instantiateResolved(carProvider));
  3186. * ```
  3187. */
  3188. Injector.prototype.instantiateResolved = function (provider) {
  3189. return this._instantiateProvider(provider, Visibility.PublicAndPrivate);
  3190. };
  3191. /** @internal */
  3192. Injector.prototype._new = function (provider, visibility) {
  3193. if (this._constructionCounter++ > this._strategy.getMaxNumberOfObjects()) {
  3194. throw new exceptions_1.CyclicDependencyError(this, provider.key);
  3195. }
  3196. return this._instantiateProvider(provider, visibility);
  3197. };
  3198. Injector.prototype._instantiateProvider = function (provider, visibility) {
  3199. if (provider.multiProvider) {
  3200. var res = collection_1.ListWrapper.createFixedSize(provider.resolvedFactories.length);
  3201. for (var i = 0; i < provider.resolvedFactories.length; ++i) {
  3202. res[i] = this._instantiate(provider, provider.resolvedFactories[i], visibility);
  3203. }
  3204. return res;
  3205. }
  3206. else {
  3207. return this._instantiate(provider, provider.resolvedFactories[0], visibility);
  3208. }
  3209. };
  3210. Injector.prototype._instantiate = function (provider, resolvedFactory, visibility) {
  3211. var factory = resolvedFactory.factory;
  3212. var deps = resolvedFactory.dependencies;
  3213. var length = deps.length;
  3214. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16, d17, d18, d19;
  3215. try {
  3216. d0 = length > 0 ? this._getByDependency(provider, deps[0], visibility) : null;
  3217. d1 = length > 1 ? this._getByDependency(provider, deps[1], visibility) : null;
  3218. d2 = length > 2 ? this._getByDependency(provider, deps[2], visibility) : null;
  3219. d3 = length > 3 ? this._getByDependency(provider, deps[3], visibility) : null;
  3220. d4 = length > 4 ? this._getByDependency(provider, deps[4], visibility) : null;
  3221. d5 = length > 5 ? this._getByDependency(provider, deps[5], visibility) : null;
  3222. d6 = length > 6 ? this._getByDependency(provider, deps[6], visibility) : null;
  3223. d7 = length > 7 ? this._getByDependency(provider, deps[7], visibility) : null;
  3224. d8 = length > 8 ? this._getByDependency(provider, deps[8], visibility) : null;
  3225. d9 = length > 9 ? this._getByDependency(provider, deps[9], visibility) : null;
  3226. d10 = length > 10 ? this._getByDependency(provider, deps[10], visibility) : null;
  3227. d11 = length > 11 ? this._getByDependency(provider, deps[11], visibility) : null;
  3228. d12 = length > 12 ? this._getByDependency(provider, deps[12], visibility) : null;
  3229. d13 = length > 13 ? this._getByDependency(provider, deps[13], visibility) : null;
  3230. d14 = length > 14 ? this._getByDependency(provider, deps[14], visibility) : null;
  3231. d15 = length > 15 ? this._getByDependency(provider, deps[15], visibility) : null;
  3232. d16 = length > 16 ? this._getByDependency(provider, deps[16], visibility) : null;
  3233. d17 = length > 17 ? this._getByDependency(provider, deps[17], visibility) : null;
  3234. d18 = length > 18 ? this._getByDependency(provider, deps[18], visibility) : null;
  3235. d19 = length > 19 ? this._getByDependency(provider, deps[19], visibility) : null;
  3236. }
  3237. catch (e) {
  3238. if (e instanceof exceptions_1.AbstractProviderError || e instanceof exceptions_1.InstantiationError) {
  3239. e.addKey(this, provider.key);
  3240. }
  3241. throw e;
  3242. }
  3243. var obj;
  3244. try {
  3245. switch (length) {
  3246. case 0:
  3247. obj = factory();
  3248. break;
  3249. case 1:
  3250. obj = factory(d0);
  3251. break;
  3252. case 2:
  3253. obj = factory(d0, d1);
  3254. break;
  3255. case 3:
  3256. obj = factory(d0, d1, d2);
  3257. break;
  3258. case 4:
  3259. obj = factory(d0, d1, d2, d3);
  3260. break;
  3261. case 5:
  3262. obj = factory(d0, d1, d2, d3, d4);
  3263. break;
  3264. case 6:
  3265. obj = factory(d0, d1, d2, d3, d4, d5);
  3266. break;
  3267. case 7:
  3268. obj = factory(d0, d1, d2, d3, d4, d5, d6);
  3269. break;
  3270. case 8:
  3271. obj = factory(d0, d1, d2, d3, d4, d5, d6, d7);
  3272. break;
  3273. case 9:
  3274. obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8);
  3275. break;
  3276. case 10:
  3277. obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9);
  3278. break;
  3279. case 11:
  3280. obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10);
  3281. break;
  3282. case 12:
  3283. obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11);
  3284. break;
  3285. case 13:
  3286. obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12);
  3287. break;
  3288. case 14:
  3289. obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13);
  3290. break;
  3291. case 15:
  3292. obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14);
  3293. break;
  3294. case 16:
  3295. obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15);
  3296. break;
  3297. case 17:
  3298. obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16);
  3299. break;
  3300. case 18:
  3301. obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16, d17);
  3302. break;
  3303. case 19:
  3304. obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16, d17, d18);
  3305. break;
  3306. case 20:
  3307. obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16, d17, d18, d19);
  3308. break;
  3309. }
  3310. }
  3311. catch (e) {
  3312. throw new exceptions_1.InstantiationError(this, e, e.stack, provider.key);
  3313. }
  3314. return obj;
  3315. };
  3316. Injector.prototype._getByDependency = function (provider, dep, providerVisibility) {
  3317. var special = lang_1.isPresent(this._depProvider) ?
  3318. this._depProvider.getDependency(this, provider, dep) :
  3319. exports.UNDEFINED;
  3320. if (special !== exports.UNDEFINED) {
  3321. return special;
  3322. }
  3323. else {
  3324. return this._getByKey(dep.key, dep.lowerBoundVisibility, dep.upperBoundVisibility, dep.optional, providerVisibility);
  3325. }
  3326. };
  3327. Injector.prototype._getByKey = function (key, lowerBoundVisibility, upperBoundVisibility, optional, providerVisibility) {
  3328. if (key === INJECTOR_KEY) {
  3329. return this;
  3330. }
  3331. if (upperBoundVisibility instanceof metadata_1.SelfMetadata) {
  3332. return this._getByKeySelf(key, optional, providerVisibility);
  3333. }
  3334. else if (upperBoundVisibility instanceof metadata_1.HostMetadata) {
  3335. return this._getByKeyHost(key, optional, providerVisibility, lowerBoundVisibility);
  3336. }
  3337. else {
  3338. return this._getByKeyDefault(key, optional, providerVisibility, lowerBoundVisibility);
  3339. }
  3340. };
  3341. /** @internal */
  3342. Injector.prototype._throwOrNull = function (key, optional) {
  3343. if (optional) {
  3344. return null;
  3345. }
  3346. else {
  3347. throw new exceptions_1.NoProviderError(this, key);
  3348. }
  3349. };
  3350. /** @internal */
  3351. Injector.prototype._getByKeySelf = function (key, optional, providerVisibility) {
  3352. var obj = this._strategy.getObjByKeyId(key.id, providerVisibility);
  3353. return (obj !== exports.UNDEFINED) ? obj : this._throwOrNull(key, optional);
  3354. };
  3355. /** @internal */
  3356. Injector.prototype._getByKeyHost = function (key, optional, providerVisibility, lowerBoundVisibility) {
  3357. var inj = this;
  3358. if (lowerBoundVisibility instanceof metadata_1.SkipSelfMetadata) {
  3359. if (inj._isHost) {
  3360. return this._getPrivateDependency(key, optional, inj);
  3361. }
  3362. else {
  3363. inj = inj._parent;
  3364. }
  3365. }
  3366. while (inj != null) {
  3367. var obj = inj._strategy.getObjByKeyId(key.id, providerVisibility);
  3368. if (obj !== exports.UNDEFINED)
  3369. return obj;
  3370. if (lang_1.isPresent(inj._parent) && inj._isHost) {
  3371. return this._getPrivateDependency(key, optional, inj);
  3372. }
  3373. else {
  3374. inj = inj._parent;
  3375. }
  3376. }
  3377. return this._throwOrNull(key, optional);
  3378. };
  3379. /** @internal */
  3380. Injector.prototype._getPrivateDependency = function (key, optional, inj) {
  3381. var obj = inj._parent._strategy.getObjByKeyId(key.id, Visibility.Private);
  3382. return (obj !== exports.UNDEFINED) ? obj : this._throwOrNull(key, optional);
  3383. };
  3384. /** @internal */
  3385. Injector.prototype._getByKeyDefault = function (key, optional, providerVisibility, lowerBoundVisibility) {
  3386. var inj = this;
  3387. if (lowerBoundVisibility instanceof metadata_1.SkipSelfMetadata) {
  3388. providerVisibility = inj._isHost ? Visibility.PublicAndPrivate : Visibility.Public;
  3389. inj = inj._parent;
  3390. }
  3391. while (inj != null) {
  3392. var obj = inj._strategy.getObjByKeyId(key.id, providerVisibility);
  3393. if (obj !== exports.UNDEFINED)
  3394. return obj;
  3395. providerVisibility = inj._isHost ? Visibility.PublicAndPrivate : Visibility.Public;
  3396. inj = inj._parent;
  3397. }
  3398. return this._throwOrNull(key, optional);
  3399. };
  3400. Object.defineProperty(Injector.prototype, "displayName", {
  3401. get: function () {
  3402. return "Injector(providers: [" + _mapProviders(this, function (b) { return (" \"" + b.key.displayName + "\" "); }).join(", ") + "])";
  3403. },
  3404. enumerable: true,
  3405. configurable: true
  3406. });
  3407. Injector.prototype.toString = function () { return this.displayName; };
  3408. return Injector;
  3409. })();
  3410. exports.Injector = Injector;
  3411. var INJECTOR_KEY = key_1.Key.get(Injector);
  3412. function _mapProviders(injector, fn) {
  3413. var res = [];
  3414. for (var i = 0; i < injector._proto.numberOfProviders; ++i) {
  3415. res.push(fn(injector._proto.getProviderAtIndex(i)));
  3416. }
  3417. return res;
  3418. }
  3419. /***/ },
  3420. /* 12 */
  3421. /***/ function(module, exports, __webpack_require__) {
  3422. var lang_1 = __webpack_require__(5);
  3423. exports.Map = lang_1.global.Map;
  3424. exports.Set = lang_1.global.Set;
  3425. // Safari and Internet Explorer do not support the iterable parameter to the
  3426. // Map constructor. We work around that by manually adding the items.
  3427. var createMapFromPairs = (function () {
  3428. try {
  3429. if (new exports.Map([[1, 2]]).size === 1) {
  3430. return function createMapFromPairs(pairs) { return new exports.Map(pairs); };
  3431. }
  3432. }
  3433. catch (e) {
  3434. }
  3435. return function createMapAndPopulateFromPairs(pairs) {
  3436. var map = new exports.Map();
  3437. for (var i = 0; i < pairs.length; i++) {
  3438. var pair = pairs[i];
  3439. map.set(pair[0], pair[1]);
  3440. }
  3441. return map;
  3442. };
  3443. })();
  3444. var createMapFromMap = (function () {
  3445. try {
  3446. if (new exports.Map(new exports.Map())) {
  3447. return function createMapFromMap(m) { return new exports.Map(m); };
  3448. }
  3449. }
  3450. catch (e) {
  3451. }
  3452. return function createMapAndPopulateFromMap(m) {
  3453. var map = new exports.Map();
  3454. m.forEach(function (v, k) { map.set(k, v); });
  3455. return map;
  3456. };
  3457. })();
  3458. var _clearValues = (function () {
  3459. if ((new exports.Map()).keys().next) {
  3460. return function _clearValues(m) {
  3461. var keyIterator = m.keys();
  3462. var k;
  3463. while (!((k = keyIterator.next()).done)) {
  3464. m.set(k.value, null);
  3465. }
  3466. };
  3467. }
  3468. else {
  3469. return function _clearValuesWithForeEach(m) {
  3470. m.forEach(function (v, k) { m.set(k, null); });
  3471. };
  3472. }
  3473. })();
  3474. // Safari doesn't implement MapIterator.next(), which is used is Traceur's polyfill of Array.from
  3475. // TODO(mlaval): remove the work around once we have a working polyfill of Array.from
  3476. var _arrayFromMap = (function () {
  3477. try {
  3478. if ((new exports.Map()).values().next) {
  3479. return function createArrayFromMap(m, getValues) {
  3480. return getValues ? Array.from(m.values()) : Array.from(m.keys());
  3481. };
  3482. }
  3483. }
  3484. catch (e) {
  3485. }
  3486. return function createArrayFromMapWithForeach(m, getValues) {
  3487. var res = ListWrapper.createFixedSize(m.size), i = 0;
  3488. m.forEach(function (v, k) {
  3489. res[i] = getValues ? v : k;
  3490. i++;
  3491. });
  3492. return res;
  3493. };
  3494. })();
  3495. var MapWrapper = (function () {
  3496. function MapWrapper() {
  3497. }
  3498. MapWrapper.clone = function (m) { return createMapFromMap(m); };
  3499. MapWrapper.createFromStringMap = function (stringMap) {
  3500. var result = new exports.Map();
  3501. for (var prop in stringMap) {
  3502. result.set(prop, stringMap[prop]);
  3503. }
  3504. return result;
  3505. };
  3506. MapWrapper.toStringMap = function (m) {
  3507. var r = {};
  3508. m.forEach(function (v, k) { return r[k] = v; });
  3509. return r;
  3510. };
  3511. MapWrapper.createFromPairs = function (pairs) { return createMapFromPairs(pairs); };
  3512. MapWrapper.clearValues = function (m) { _clearValues(m); };
  3513. MapWrapper.iterable = function (m) { return m; };
  3514. MapWrapper.keys = function (m) { return _arrayFromMap(m, false); };
  3515. MapWrapper.values = function (m) { return _arrayFromMap(m, true); };
  3516. return MapWrapper;
  3517. })();
  3518. exports.MapWrapper = MapWrapper;
  3519. /**
  3520. * Wraps Javascript Objects
  3521. */
  3522. var StringMapWrapper = (function () {
  3523. function StringMapWrapper() {
  3524. }
  3525. StringMapWrapper.create = function () {
  3526. // Note: We are not using Object.create(null) here due to
  3527. // performance!
  3528. // http://jsperf.com/ng2-object-create-null
  3529. return {};
  3530. };
  3531. StringMapWrapper.contains = function (map, key) {
  3532. return map.hasOwnProperty(key);
  3533. };
  3534. StringMapWrapper.get = function (map, key) {
  3535. return map.hasOwnProperty(key) ? map[key] : undefined;
  3536. };
  3537. StringMapWrapper.set = function (map, key, value) { map[key] = value; };
  3538. StringMapWrapper.keys = function (map) { return Object.keys(map); };
  3539. StringMapWrapper.isEmpty = function (map) {
  3540. for (var prop in map) {
  3541. return false;
  3542. }
  3543. return true;
  3544. };
  3545. StringMapWrapper.delete = function (map, key) { delete map[key]; };
  3546. StringMapWrapper.forEach = function (map, callback) {
  3547. for (var prop in map) {
  3548. if (map.hasOwnProperty(prop)) {
  3549. callback(map[prop], prop);
  3550. }
  3551. }
  3552. };
  3553. StringMapWrapper.merge = function (m1, m2) {
  3554. var m = {};
  3555. for (var attr in m1) {
  3556. if (m1.hasOwnProperty(attr)) {
  3557. m[attr] = m1[attr];
  3558. }
  3559. }
  3560. for (var attr in m2) {
  3561. if (m2.hasOwnProperty(attr)) {
  3562. m[attr] = m2[attr];
  3563. }
  3564. }
  3565. return m;
  3566. };
  3567. StringMapWrapper.equals = function (m1, m2) {
  3568. var k1 = Object.keys(m1);
  3569. var k2 = Object.keys(m2);
  3570. if (k1.length != k2.length) {
  3571. return false;
  3572. }
  3573. var key;
  3574. for (var i = 0; i < k1.length; i++) {
  3575. key = k1[i];
  3576. if (m1[key] !== m2[key]) {
  3577. return false;
  3578. }
  3579. }
  3580. return true;
  3581. };
  3582. return StringMapWrapper;
  3583. })();
  3584. exports.StringMapWrapper = StringMapWrapper;
  3585. var ListWrapper = (function () {
  3586. function ListWrapper() {
  3587. }
  3588. // JS has no way to express a statically fixed size list, but dart does so we
  3589. // keep both methods.
  3590. ListWrapper.createFixedSize = function (size) { return new Array(size); };
  3591. ListWrapper.createGrowableSize = function (size) { return new Array(size); };
  3592. ListWrapper.clone = function (array) { return array.slice(0); };
  3593. ListWrapper.forEachWithIndex = function (array, fn) {
  3594. for (var i = 0; i < array.length; i++) {
  3595. fn(array[i], i);
  3596. }
  3597. };
  3598. ListWrapper.first = function (array) {
  3599. if (!array)
  3600. return null;
  3601. return array[0];
  3602. };
  3603. ListWrapper.last = function (array) {
  3604. if (!array || array.length == 0)
  3605. return null;
  3606. return array[array.length - 1];
  3607. };
  3608. ListWrapper.indexOf = function (array, value, startIndex) {
  3609. if (startIndex === void 0) { startIndex = 0; }
  3610. return array.indexOf(value, startIndex);
  3611. };
  3612. ListWrapper.contains = function (list, el) { return list.indexOf(el) !== -1; };
  3613. ListWrapper.reversed = function (array) {
  3614. var a = ListWrapper.clone(array);
  3615. return a.reverse();
  3616. };
  3617. ListWrapper.concat = function (a, b) { return a.concat(b); };
  3618. ListWrapper.insert = function (list, index, value) { list.splice(index, 0, value); };
  3619. ListWrapper.removeAt = function (list, index) {
  3620. var res = list[index];
  3621. list.splice(index, 1);
  3622. return res;
  3623. };
  3624. ListWrapper.removeAll = function (list, items) {
  3625. for (var i = 0; i < items.length; ++i) {
  3626. var index = list.indexOf(items[i]);
  3627. list.splice(index, 1);
  3628. }
  3629. };
  3630. ListWrapper.remove = function (list, el) {
  3631. var index = list.indexOf(el);
  3632. if (index > -1) {
  3633. list.splice(index, 1);
  3634. return true;
  3635. }
  3636. return false;
  3637. };
  3638. ListWrapper.clear = function (list) { list.length = 0; };
  3639. ListWrapper.isEmpty = function (list) { return list.length == 0; };
  3640. ListWrapper.fill = function (list, value, start, end) {
  3641. if (start === void 0) { start = 0; }
  3642. if (end === void 0) { end = null; }
  3643. list.fill(value, start, end === null ? list.length : end);
  3644. };
  3645. ListWrapper.equals = function (a, b) {
  3646. if (a.length != b.length)
  3647. return false;
  3648. for (var i = 0; i < a.length; ++i) {
  3649. if (a[i] !== b[i])
  3650. return false;
  3651. }
  3652. return true;
  3653. };
  3654. ListWrapper.slice = function (l, from, to) {
  3655. if (from === void 0) { from = 0; }
  3656. if (to === void 0) { to = null; }
  3657. return l.slice(from, to === null ? undefined : to);
  3658. };
  3659. ListWrapper.splice = function (l, from, length) { return l.splice(from, length); };
  3660. ListWrapper.sort = function (l, compareFn) {
  3661. if (lang_1.isPresent(compareFn)) {
  3662. l.sort(compareFn);
  3663. }
  3664. else {
  3665. l.sort();
  3666. }
  3667. };
  3668. ListWrapper.toString = function (l) { return l.toString(); };
  3669. ListWrapper.toJSON = function (l) { return JSON.stringify(l); };
  3670. ListWrapper.maximum = function (list, predicate) {
  3671. if (list.length == 0) {
  3672. return null;
  3673. }
  3674. var solution = null;
  3675. var maxValue = -Infinity;
  3676. for (var index = 0; index < list.length; index++) {
  3677. var candidate = list[index];
  3678. if (lang_1.isBlank(candidate)) {
  3679. continue;
  3680. }
  3681. var candidateValue = predicate(candidate);
  3682. if (candidateValue > maxValue) {
  3683. solution = candidate;
  3684. maxValue = candidateValue;
  3685. }
  3686. }
  3687. return solution;
  3688. };
  3689. return ListWrapper;
  3690. })();
  3691. exports.ListWrapper = ListWrapper;
  3692. function isListLikeIterable(obj) {
  3693. if (!lang_1.isJsObject(obj))
  3694. return false;
  3695. return lang_1.isArray(obj) ||
  3696. (!(obj instanceof exports.Map) &&
  3697. lang_1.getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
  3698. }
  3699. exports.isListLikeIterable = isListLikeIterable;
  3700. function iterateListLike(obj, fn) {
  3701. if (lang_1.isArray(obj)) {
  3702. for (var i = 0; i < obj.length; i++) {
  3703. fn(obj[i]);
  3704. }
  3705. }
  3706. else {
  3707. var iterator = obj[lang_1.getSymbolIterator()]();
  3708. var item;
  3709. while (!((item = iterator.next()).done)) {
  3710. fn(item.value);
  3711. }
  3712. }
  3713. }
  3714. exports.iterateListLike = iterateListLike;
  3715. // Safari and Internet Explorer do not support the iterable parameter to the
  3716. // Set constructor. We work around that by manually adding the items.
  3717. var createSetFromList = (function () {
  3718. var test = new exports.Set([1, 2, 3]);
  3719. if (test.size === 3) {
  3720. return function createSetFromList(lst) { return new exports.Set(lst); };
  3721. }
  3722. else {
  3723. return function createSetAndPopulateFromList(lst) {
  3724. var res = new exports.Set(lst);
  3725. if (res.size !== lst.length) {
  3726. for (var i = 0; i < lst.length; i++) {
  3727. res.add(lst[i]);
  3728. }
  3729. }
  3730. return res;
  3731. };
  3732. }
  3733. })();
  3734. var SetWrapper = (function () {
  3735. function SetWrapper() {
  3736. }
  3737. SetWrapper.createFromList = function (lst) { return createSetFromList(lst); };
  3738. SetWrapper.has = function (s, key) { return s.has(key); };
  3739. SetWrapper.delete = function (m, k) { m.delete(k); };
  3740. return SetWrapper;
  3741. })();
  3742. exports.SetWrapper = SetWrapper;
  3743. /***/ },
  3744. /* 13 */
  3745. /***/ function(module, exports, __webpack_require__) {
  3746. var __extends = (this && this.__extends) || function (d, b) {
  3747. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3748. function __() { this.constructor = d; }
  3749. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3750. };
  3751. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  3752. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3753. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  3754. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  3755. return c > 3 && r && Object.defineProperty(target, key, r), r;
  3756. };
  3757. var __metadata = (this && this.__metadata) || function (k, v) {
  3758. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  3759. };
  3760. var lang_1 = __webpack_require__(5);
  3761. var exceptions_1 = __webpack_require__(14);
  3762. var collection_1 = __webpack_require__(12);
  3763. var reflection_1 = __webpack_require__(16);
  3764. var key_1 = __webpack_require__(19);
  3765. var metadata_1 = __webpack_require__(7);
  3766. var exceptions_2 = __webpack_require__(21);
  3767. var forward_ref_1 = __webpack_require__(10);
  3768. /**
  3769. * `Dependency` is used by the framework to extend DI.
  3770. * This is internal to Angular and should not be used directly.
  3771. */
  3772. var Dependency = (function () {
  3773. function Dependency(key, optional, lowerBoundVisibility, upperBoundVisibility, properties) {
  3774. this.key = key;
  3775. this.optional = optional;
  3776. this.lowerBoundVisibility = lowerBoundVisibility;
  3777. this.upperBoundVisibility = upperBoundVisibility;
  3778. this.properties = properties;
  3779. }
  3780. Dependency.fromKey = function (key) { return new Dependency(key, false, null, null, []); };
  3781. return Dependency;
  3782. })();
  3783. exports.Dependency = Dependency;
  3784. var _EMPTY_LIST = lang_1.CONST_EXPR([]);
  3785. /**
  3786. * Describes how the {@link Injector} should instantiate a given token.
  3787. *
  3788. * See {@link provide}.
  3789. *
  3790. * ### Example ([live demo](http://plnkr.co/edit/GNAyj6K6PfYg2NBzgwZ5?p%3Dpreview&p=preview))
  3791. *
  3792. * ```javascript
  3793. * var injector = Injector.resolveAndCreate([
  3794. * new Provider("message", { useValue: 'Hello' })
  3795. * ]);
  3796. *
  3797. * expect(injector.get("message")).toEqual('Hello');
  3798. * ```
  3799. */
  3800. var Provider = (function () {
  3801. function Provider(token, _a) {
  3802. var useClass = _a.useClass, useValue = _a.useValue, useExisting = _a.useExisting, useFactory = _a.useFactory, deps = _a.deps, multi = _a.multi;
  3803. this.token = token;
  3804. this.useClass = useClass;
  3805. this.useValue = useValue;
  3806. this.useExisting = useExisting;
  3807. this.useFactory = useFactory;
  3808. this.dependencies = deps;
  3809. this._multi = multi;
  3810. }
  3811. Object.defineProperty(Provider.prototype, "multi", {
  3812. // TODO: Provide a full working example after alpha38 is released.
  3813. /**
  3814. * Creates multiple providers matching the same token (a multi-provider).
  3815. *
  3816. * Multi-providers are used for creating pluggable service, where the system comes
  3817. * with some default providers, and the user can register additonal providers.
  3818. * The combination of the default providers and the additional providers will be
  3819. * used to drive the behavior of the system.
  3820. *
  3821. * ### Example
  3822. *
  3823. * ```typescript
  3824. * var injector = Injector.resolveAndCreate([
  3825. * new Provider("Strings", { useValue: "String1", multi: true}),
  3826. * new Provider("Strings", { useValue: "String2", multi: true})
  3827. * ]);
  3828. *
  3829. * expect(injector.get("Strings")).toEqual(["String1", "String2"]);
  3830. * ```
  3831. *
  3832. * Multi-providers and regular providers cannot be mixed. The following
  3833. * will throw an exception:
  3834. *
  3835. * ```typescript
  3836. * var injector = Injector.resolveAndCreate([
  3837. * new Provider("Strings", { useValue: "String1", multi: true }),
  3838. * new Provider("Strings", { useValue: "String2"})
  3839. * ]);
  3840. * ```
  3841. */
  3842. get: function () { return lang_1.normalizeBool(this._multi); },
  3843. enumerable: true,
  3844. configurable: true
  3845. });
  3846. Provider = __decorate([
  3847. lang_1.CONST(),
  3848. __metadata('design:paramtypes', [Object, Object])
  3849. ], Provider);
  3850. return Provider;
  3851. })();
  3852. exports.Provider = Provider;
  3853. /**
  3854. * See {@link Provider} instead.
  3855. *
  3856. * @deprecated
  3857. */
  3858. var Binding = (function (_super) {
  3859. __extends(Binding, _super);
  3860. function Binding(token, _a) {
  3861. var toClass = _a.toClass, toValue = _a.toValue, toAlias = _a.toAlias, toFactory = _a.toFactory, deps = _a.deps, multi = _a.multi;
  3862. _super.call(this, token, {
  3863. useClass: toClass,
  3864. useValue: toValue,
  3865. useExisting: toAlias,
  3866. useFactory: toFactory,
  3867. deps: deps,
  3868. multi: multi
  3869. });
  3870. }
  3871. Object.defineProperty(Binding.prototype, "toClass", {
  3872. /**
  3873. * @deprecated
  3874. */
  3875. get: function () { return this.useClass; },
  3876. enumerable: true,
  3877. configurable: true
  3878. });
  3879. Object.defineProperty(Binding.prototype, "toAlias", {
  3880. /**
  3881. * @deprecated
  3882. */
  3883. get: function () { return this.useExisting; },
  3884. enumerable: true,
  3885. configurable: true
  3886. });
  3887. Object.defineProperty(Binding.prototype, "toFactory", {
  3888. /**
  3889. * @deprecated
  3890. */
  3891. get: function () { return this.useFactory; },
  3892. enumerable: true,
  3893. configurable: true
  3894. });
  3895. Object.defineProperty(Binding.prototype, "toValue", {
  3896. /**
  3897. * @deprecated
  3898. */
  3899. get: function () { return this.useValue; },
  3900. enumerable: true,
  3901. configurable: true
  3902. });
  3903. Binding = __decorate([
  3904. lang_1.CONST(),
  3905. __metadata('design:paramtypes', [Object, Object])
  3906. ], Binding);
  3907. return Binding;
  3908. })(Provider);
  3909. exports.Binding = Binding;
  3910. var ResolvedProvider_ = (function () {
  3911. function ResolvedProvider_(key, resolvedFactories, multiProvider) {
  3912. this.key = key;
  3913. this.resolvedFactories = resolvedFactories;
  3914. this.multiProvider = multiProvider;
  3915. }
  3916. Object.defineProperty(ResolvedProvider_.prototype, "resolvedFactory", {
  3917. get: function () { return this.resolvedFactories[0]; },
  3918. enumerable: true,
  3919. configurable: true
  3920. });
  3921. return ResolvedProvider_;
  3922. })();
  3923. exports.ResolvedProvider_ = ResolvedProvider_;
  3924. /**
  3925. * An internal resolved representation of a factory function created by resolving {@link Provider}.
  3926. */
  3927. var ResolvedFactory = (function () {
  3928. function ResolvedFactory(
  3929. /**
  3930. * Factory function which can return an instance of an object represented by a key.
  3931. */
  3932. factory,
  3933. /**
  3934. * Arguments (dependencies) to the `factory` function.
  3935. */
  3936. dependencies) {
  3937. this.factory = factory;
  3938. this.dependencies = dependencies;
  3939. }
  3940. return ResolvedFactory;
  3941. })();
  3942. exports.ResolvedFactory = ResolvedFactory;
  3943. /**
  3944. * Creates a {@link Provider}.
  3945. *
  3946. * To construct a {@link Provider}, bind a `token` to either a class, a value, a factory function,
  3947. * or
  3948. * to an existing `token`.
  3949. * See {@link ProviderBuilder} for more details.
  3950. *
  3951. * The `token` is most commonly a class or {@link angular2/di/OpaqueToken}.
  3952. *
  3953. * @deprecated
  3954. */
  3955. function bind(token) {
  3956. return new ProviderBuilder(token);
  3957. }
  3958. exports.bind = bind;
  3959. /**
  3960. * Creates a {@link Provider}.
  3961. *
  3962. * See {@link Provider} for more details.
  3963. *
  3964. * <!-- TODO: improve the docs -->
  3965. */
  3966. function provide(token, _a) {
  3967. var useClass = _a.useClass, useValue = _a.useValue, useExisting = _a.useExisting, useFactory = _a.useFactory, deps = _a.deps, multi = _a.multi;
  3968. return new Provider(token, {
  3969. useClass: useClass,
  3970. useValue: useValue,
  3971. useExisting: useExisting,
  3972. useFactory: useFactory,
  3973. deps: deps,
  3974. multi: multi
  3975. });
  3976. }
  3977. exports.provide = provide;
  3978. /**
  3979. * Helper class for the {@link bind} function.
  3980. */
  3981. var ProviderBuilder = (function () {
  3982. function ProviderBuilder(token) {
  3983. this.token = token;
  3984. }
  3985. /**
  3986. * Binds a DI token to a class.
  3987. *
  3988. * ### Example ([live demo](http://plnkr.co/edit/ZpBCSYqv6e2ud5KXLdxQ?p=preview))
  3989. *
  3990. * Because `toAlias` and `toClass` are often confused, the example contains
  3991. * both use cases for easy comparison.
  3992. *
  3993. * ```typescript
  3994. * class Vehicle {}
  3995. *
  3996. * class Car extends Vehicle {}
  3997. *
  3998. * var injectorClass = Injector.resolveAndCreate([
  3999. * Car,
  4000. * provide(Vehicle, {useClass: Car})
  4001. * ]);
  4002. * var injectorAlias = Injector.resolveAndCreate([
  4003. * Car,
  4004. * provide(Vehicle, {useExisting: Car})
  4005. * ]);
  4006. *
  4007. * expect(injectorClass.get(Vehicle)).not.toBe(injectorClass.get(Car));
  4008. * expect(injectorClass.get(Vehicle) instanceof Car).toBe(true);
  4009. *
  4010. * expect(injectorAlias.get(Vehicle)).toBe(injectorAlias.get(Car));
  4011. * expect(injectorAlias.get(Vehicle) instanceof Car).toBe(true);
  4012. * ```
  4013. */
  4014. ProviderBuilder.prototype.toClass = function (type) {
  4015. if (!lang_1.isType(type)) {
  4016. throw new exceptions_1.BaseException("Trying to create a class provider but \"" + lang_1.stringify(type) + "\" is not a class!");
  4017. }
  4018. return new Provider(this.token, { useClass: type });
  4019. };
  4020. /**
  4021. * Binds a DI token to a value.
  4022. *
  4023. * ### Example ([live demo](http://plnkr.co/edit/G024PFHmDL0cJFgfZK8O?p=preview))
  4024. *
  4025. * ```typescript
  4026. * var injector = Injector.resolveAndCreate([
  4027. * provide('message', {useValue: 'Hello'})
  4028. * ]);
  4029. *
  4030. * expect(injector.get('message')).toEqual('Hello');
  4031. * ```
  4032. */
  4033. ProviderBuilder.prototype.toValue = function (value) { return new Provider(this.token, { useValue: value }); };
  4034. /**
  4035. * Binds a DI token to an existing token.
  4036. *
  4037. * Angular will return the same instance as if the provided token was used. (This is
  4038. * in contrast to `useClass` where a separate instance of `useClass` will be returned.)
  4039. *
  4040. * ### Example ([live demo](http://plnkr.co/edit/uBaoF2pN5cfc5AfZapNw?p=preview))
  4041. *
  4042. * Because `toAlias` and `toClass` are often confused, the example contains
  4043. * both use cases for easy comparison.
  4044. *
  4045. * ```typescript
  4046. * class Vehicle {}
  4047. *
  4048. * class Car extends Vehicle {}
  4049. *
  4050. * var injectorAlias = Injector.resolveAndCreate([
  4051. * Car,
  4052. * provide(Vehicle, {useExisting: Car})
  4053. * ]);
  4054. * var injectorClass = Injector.resolveAndCreate([
  4055. * Car,
  4056. * provide(Vehicle, {useClass: Car})
  4057. * ]);
  4058. *
  4059. * expect(injectorAlias.get(Vehicle)).toBe(injectorAlias.get(Car));
  4060. * expect(injectorAlias.get(Vehicle) instanceof Car).toBe(true);
  4061. *
  4062. * expect(injectorClass.get(Vehicle)).not.toBe(injectorClass.get(Car));
  4063. * expect(injectorClass.get(Vehicle) instanceof Car).toBe(true);
  4064. * ```
  4065. */
  4066. ProviderBuilder.prototype.toAlias = function (aliasToken) {
  4067. if (lang_1.isBlank(aliasToken)) {
  4068. throw new exceptions_1.BaseException("Can not alias " + lang_1.stringify(this.token) + " to a blank value!");
  4069. }
  4070. return new Provider(this.token, { useExisting: aliasToken });
  4071. };
  4072. /**
  4073. * Binds a DI token to a function which computes the value.
  4074. *
  4075. * ### Example ([live demo](http://plnkr.co/edit/OejNIfTT3zb1iBxaIYOb?p=preview))
  4076. *
  4077. * ```typescript
  4078. * var injector = Injector.resolveAndCreate([
  4079. * provide(Number, {useFactory: () => { return 1+2; }}),
  4080. * provide(String, {useFactory: (v) => { return "Value: " + v; }, deps: [Number]})
  4081. * ]);
  4082. *
  4083. * expect(injector.get(Number)).toEqual(3);
  4084. * expect(injector.get(String)).toEqual('Value: 3');
  4085. * ```
  4086. */
  4087. ProviderBuilder.prototype.toFactory = function (factory, dependencies) {
  4088. if (!lang_1.isFunction(factory)) {
  4089. throw new exceptions_1.BaseException("Trying to create a factory provider but \"" + lang_1.stringify(factory) + "\" is not a function!");
  4090. }
  4091. return new Provider(this.token, { useFactory: factory, deps: dependencies });
  4092. };
  4093. return ProviderBuilder;
  4094. })();
  4095. exports.ProviderBuilder = ProviderBuilder;
  4096. /**
  4097. * Resolve a single provider.
  4098. */
  4099. function resolveFactory(provider) {
  4100. var factoryFn;
  4101. var resolvedDeps;
  4102. if (lang_1.isPresent(provider.useClass)) {
  4103. var useClass = forward_ref_1.resolveForwardRef(provider.useClass);
  4104. factoryFn = reflection_1.reflector.factory(useClass);
  4105. resolvedDeps = _dependenciesFor(useClass);
  4106. }
  4107. else if (lang_1.isPresent(provider.useExisting)) {
  4108. factoryFn = function (aliasInstance) { return aliasInstance; };
  4109. resolvedDeps = [Dependency.fromKey(key_1.Key.get(provider.useExisting))];
  4110. }
  4111. else if (lang_1.isPresent(provider.useFactory)) {
  4112. factoryFn = provider.useFactory;
  4113. resolvedDeps = _constructDependencies(provider.useFactory, provider.dependencies);
  4114. }
  4115. else {
  4116. factoryFn = function () { return provider.useValue; };
  4117. resolvedDeps = _EMPTY_LIST;
  4118. }
  4119. return new ResolvedFactory(factoryFn, resolvedDeps);
  4120. }
  4121. exports.resolveFactory = resolveFactory;
  4122. /**
  4123. * Converts the {@link Provider} into {@link ResolvedProvider}.
  4124. *
  4125. * {@link Injector} internally only uses {@link ResolvedProvider}, {@link Provider} contains
  4126. * convenience provider syntax.
  4127. */
  4128. function resolveProvider(provider) {
  4129. return new ResolvedProvider_(key_1.Key.get(provider.token), [resolveFactory(provider)], false);
  4130. }
  4131. exports.resolveProvider = resolveProvider;
  4132. /**
  4133. * Resolve a list of Providers.
  4134. */
  4135. function resolveProviders(providers) {
  4136. var normalized = _createListOfProviders(_normalizeProviders(providers, new Map()));
  4137. return normalized.map(function (b) {
  4138. if (b instanceof _NormalizedProvider) {
  4139. return new ResolvedProvider_(b.key, [b.resolvedFactory], false);
  4140. }
  4141. else {
  4142. var arr = b;
  4143. return new ResolvedProvider_(arr[0].key, arr.map(function (_) { return _.resolvedFactory; }), true);
  4144. }
  4145. });
  4146. }
  4147. exports.resolveProviders = resolveProviders;
  4148. /**
  4149. * The algorithm works as follows:
  4150. *
  4151. * [Provider] -> [_NormalizedProvider|[_NormalizedProvider]] -> [ResolvedProvider]
  4152. *
  4153. * _NormalizedProvider is essentially a resolved provider before it was grouped by key.
  4154. */
  4155. var _NormalizedProvider = (function () {
  4156. function _NormalizedProvider(key, resolvedFactory) {
  4157. this.key = key;
  4158. this.resolvedFactory = resolvedFactory;
  4159. }
  4160. return _NormalizedProvider;
  4161. })();
  4162. function _createListOfProviders(flattenedProviders) {
  4163. return collection_1.MapWrapper.values(flattenedProviders);
  4164. }
  4165. function _normalizeProviders(providers, res) {
  4166. providers.forEach(function (b) {
  4167. if (b instanceof lang_1.Type) {
  4168. _normalizeProvider(provide(b, { useClass: b }), res);
  4169. }
  4170. else if (b instanceof Provider) {
  4171. _normalizeProvider(b, res);
  4172. }
  4173. else if (b instanceof Array) {
  4174. _normalizeProviders(b, res);
  4175. }
  4176. else if (b instanceof ProviderBuilder) {
  4177. throw new exceptions_2.InvalidProviderError(b.token);
  4178. }
  4179. else {
  4180. throw new exceptions_2.InvalidProviderError(b);
  4181. }
  4182. });
  4183. return res;
  4184. }
  4185. function _normalizeProvider(b, res) {
  4186. var key = key_1.Key.get(b.token);
  4187. var factory = resolveFactory(b);
  4188. var normalized = new _NormalizedProvider(key, factory);
  4189. if (b.multi) {
  4190. var existingProvider = res.get(key.id);
  4191. if (existingProvider instanceof Array) {
  4192. existingProvider.push(normalized);
  4193. }
  4194. else if (lang_1.isBlank(existingProvider)) {
  4195. res.set(key.id, [normalized]);
  4196. }
  4197. else {
  4198. throw new exceptions_2.MixingMultiProvidersWithRegularProvidersError(existingProvider, b);
  4199. }
  4200. }
  4201. else {
  4202. var existingProvider = res.get(key.id);
  4203. if (existingProvider instanceof Array) {
  4204. throw new exceptions_2.MixingMultiProvidersWithRegularProvidersError(existingProvider, b);
  4205. }
  4206. res.set(key.id, normalized);
  4207. }
  4208. }
  4209. function _constructDependencies(factoryFunction, dependencies) {
  4210. if (lang_1.isBlank(dependencies)) {
  4211. return _dependenciesFor(factoryFunction);
  4212. }
  4213. else {
  4214. var params = dependencies.map(function (t) { return [t]; });
  4215. return dependencies.map(function (t) { return _extractToken(factoryFunction, t, params); });
  4216. }
  4217. }
  4218. function _dependenciesFor(typeOrFunc) {
  4219. var params = reflection_1.reflector.parameters(typeOrFunc);
  4220. if (lang_1.isBlank(params))
  4221. return [];
  4222. if (params.some(lang_1.isBlank)) {
  4223. throw new exceptions_2.NoAnnotationError(typeOrFunc, params);
  4224. }
  4225. return params.map(function (p) { return _extractToken(typeOrFunc, p, params); });
  4226. }
  4227. function _extractToken(typeOrFunc, metadata /*any[] | any*/, params) {
  4228. var depProps = [];
  4229. var token = null;
  4230. var optional = false;
  4231. if (!lang_1.isArray(metadata)) {
  4232. if (metadata instanceof metadata_1.InjectMetadata) {
  4233. return _createDependency(metadata.token, optional, null, null, depProps);
  4234. }
  4235. else {
  4236. return _createDependency(metadata, optional, null, null, depProps);
  4237. }
  4238. }
  4239. var lowerBoundVisibility = null;
  4240. var upperBoundVisibility = null;
  4241. for (var i = 0; i < metadata.length; ++i) {
  4242. var paramMetadata = metadata[i];
  4243. if (paramMetadata instanceof lang_1.Type) {
  4244. token = paramMetadata;
  4245. }
  4246. else if (paramMetadata instanceof metadata_1.InjectMetadata) {
  4247. token = paramMetadata.token;
  4248. }
  4249. else if (paramMetadata instanceof metadata_1.OptionalMetadata) {
  4250. optional = true;
  4251. }
  4252. else if (paramMetadata instanceof metadata_1.SelfMetadata) {
  4253. upperBoundVisibility = paramMetadata;
  4254. }
  4255. else if (paramMetadata instanceof metadata_1.HostMetadata) {
  4256. upperBoundVisibility = paramMetadata;
  4257. }
  4258. else if (paramMetadata instanceof metadata_1.SkipSelfMetadata) {
  4259. lowerBoundVisibility = paramMetadata;
  4260. }
  4261. else if (paramMetadata instanceof metadata_1.DependencyMetadata) {
  4262. if (lang_1.isPresent(paramMetadata.token)) {
  4263. token = paramMetadata.token;
  4264. }
  4265. depProps.push(paramMetadata);
  4266. }
  4267. }
  4268. token = forward_ref_1.resolveForwardRef(token);
  4269. if (lang_1.isPresent(token)) {
  4270. return _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility, depProps);
  4271. }
  4272. else {
  4273. throw new exceptions_2.NoAnnotationError(typeOrFunc, params);
  4274. }
  4275. }
  4276. function _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility, depProps) {
  4277. return new Dependency(key_1.Key.get(token), optional, lowerBoundVisibility, upperBoundVisibility, depProps);
  4278. }
  4279. /***/ },
  4280. /* 14 */
  4281. /***/ function(module, exports, __webpack_require__) {
  4282. var __extends = (this && this.__extends) || function (d, b) {
  4283. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4284. function __() { this.constructor = d; }
  4285. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4286. };
  4287. var exception_handler_1 = __webpack_require__(15);
  4288. var exception_handler_2 = __webpack_require__(15);
  4289. exports.ExceptionHandler = exception_handler_2.ExceptionHandler;
  4290. var BaseException = (function (_super) {
  4291. __extends(BaseException, _super);
  4292. function BaseException(message) {
  4293. if (message === void 0) { message = "--"; }
  4294. _super.call(this, message);
  4295. this.message = message;
  4296. this.stack = (new Error(message)).stack;
  4297. }
  4298. BaseException.prototype.toString = function () { return this.message; };
  4299. return BaseException;
  4300. })(Error);
  4301. exports.BaseException = BaseException;
  4302. /**
  4303. * Wraps an exception and provides additional context or information.
  4304. */
  4305. var WrappedException = (function (_super) {
  4306. __extends(WrappedException, _super);
  4307. function WrappedException(_wrapperMessage, _originalException, _originalStack, _context) {
  4308. _super.call(this, _wrapperMessage);
  4309. this._wrapperMessage = _wrapperMessage;
  4310. this._originalException = _originalException;
  4311. this._originalStack = _originalStack;
  4312. this._context = _context;
  4313. this._wrapperStack = (new Error(_wrapperMessage)).stack;
  4314. }
  4315. Object.defineProperty(WrappedException.prototype, "wrapperMessage", {
  4316. get: function () { return this._wrapperMessage; },
  4317. enumerable: true,
  4318. configurable: true
  4319. });
  4320. Object.defineProperty(WrappedException.prototype, "wrapperStack", {
  4321. get: function () { return this._wrapperStack; },
  4322. enumerable: true,
  4323. configurable: true
  4324. });
  4325. Object.defineProperty(WrappedException.prototype, "originalException", {
  4326. get: function () { return this._originalException; },
  4327. enumerable: true,
  4328. configurable: true
  4329. });
  4330. Object.defineProperty(WrappedException.prototype, "originalStack", {
  4331. get: function () { return this._originalStack; },
  4332. enumerable: true,
  4333. configurable: true
  4334. });
  4335. Object.defineProperty(WrappedException.prototype, "context", {
  4336. get: function () { return this._context; },
  4337. enumerable: true,
  4338. configurable: true
  4339. });
  4340. Object.defineProperty(WrappedException.prototype, "message", {
  4341. get: function () { return exception_handler_1.ExceptionHandler.exceptionToString(this); },
  4342. enumerable: true,
  4343. configurable: true
  4344. });
  4345. WrappedException.prototype.toString = function () { return this.message; };
  4346. return WrappedException;
  4347. })(Error);
  4348. exports.WrappedException = WrappedException;
  4349. function makeTypeError(message) {
  4350. return new TypeError(message);
  4351. }
  4352. exports.makeTypeError = makeTypeError;
  4353. function unimplemented() {
  4354. throw new BaseException('unimplemented');
  4355. }
  4356. exports.unimplemented = unimplemented;
  4357. /***/ },
  4358. /* 15 */
  4359. /***/ function(module, exports, __webpack_require__) {
  4360. var lang_1 = __webpack_require__(5);
  4361. var exceptions_1 = __webpack_require__(14);
  4362. var collection_1 = __webpack_require__(12);
  4363. var _ArrayLogger = (function () {
  4364. function _ArrayLogger() {
  4365. this.res = [];
  4366. }
  4367. _ArrayLogger.prototype.log = function (s) { this.res.push(s); };
  4368. _ArrayLogger.prototype.logError = function (s) { this.res.push(s); };
  4369. _ArrayLogger.prototype.logGroup = function (s) { this.res.push(s); };
  4370. _ArrayLogger.prototype.logGroupEnd = function () { };
  4371. ;
  4372. return _ArrayLogger;
  4373. })();
  4374. /**
  4375. * Provides a hook for centralized exception handling.
  4376. *
  4377. * The default implementation of `ExceptionHandler` prints error messages to the `Console`. To
  4378. * intercept error handling,
  4379. * write a custom exception handler that replaces this default as appropriate for your app.
  4380. *
  4381. * ### Example
  4382. *
  4383. * ```javascript
  4384. *
  4385. * class MyExceptionHandler implements ExceptionHandler {
  4386. * call(error, stackTrace = null, reason = null) {
  4387. * // do something with the exception
  4388. * }
  4389. * }
  4390. *
  4391. * bootstrap(MyApp, [provide(ExceptionHandler, {useClass: MyExceptionHandler})])
  4392. *
  4393. * ```
  4394. */
  4395. var ExceptionHandler = (function () {
  4396. function ExceptionHandler(_logger, _rethrowException) {
  4397. if (_rethrowException === void 0) { _rethrowException = true; }
  4398. this._logger = _logger;
  4399. this._rethrowException = _rethrowException;
  4400. }
  4401. ExceptionHandler.exceptionToString = function (exception, stackTrace, reason) {
  4402. if (stackTrace === void 0) { stackTrace = null; }
  4403. if (reason === void 0) { reason = null; }
  4404. var l = new _ArrayLogger();
  4405. var e = new ExceptionHandler(l, false);
  4406. e.call(exception, stackTrace, reason);
  4407. return l.res.join("\n");
  4408. };
  4409. ExceptionHandler.prototype.call = function (exception, stackTrace, reason) {
  4410. if (stackTrace === void 0) { stackTrace = null; }
  4411. if (reason === void 0) { reason = null; }
  4412. var originalException = this._findOriginalException(exception);
  4413. var originalStack = this._findOriginalStack(exception);
  4414. var context = this._findContext(exception);
  4415. this._logger.logGroup("EXCEPTION: " + this._extractMessage(exception));
  4416. if (lang_1.isPresent(stackTrace) && lang_1.isBlank(originalStack)) {
  4417. this._logger.logError("STACKTRACE:");
  4418. this._logger.logError(this._longStackTrace(stackTrace));
  4419. }
  4420. if (lang_1.isPresent(reason)) {
  4421. this._logger.logError("REASON: " + reason);
  4422. }
  4423. if (lang_1.isPresent(originalException)) {
  4424. this._logger.logError("ORIGINAL EXCEPTION: " + this._extractMessage(originalException));
  4425. }
  4426. if (lang_1.isPresent(originalStack)) {
  4427. this._logger.logError("ORIGINAL STACKTRACE:");
  4428. this._logger.logError(this._longStackTrace(originalStack));
  4429. }
  4430. if (lang_1.isPresent(context)) {
  4431. this._logger.logError("ERROR CONTEXT:");
  4432. this._logger.logError(context);
  4433. }
  4434. this._logger.logGroupEnd();
  4435. // We rethrow exceptions, so operations like 'bootstrap' will result in an error
  4436. // when an exception happens. If we do not rethrow, bootstrap will always succeed.
  4437. if (this._rethrowException)
  4438. throw exception;
  4439. };
  4440. /** @internal */
  4441. ExceptionHandler.prototype._extractMessage = function (exception) {
  4442. return exception instanceof exceptions_1.WrappedException ? exception.wrapperMessage : exception.toString();
  4443. };
  4444. /** @internal */
  4445. ExceptionHandler.prototype._longStackTrace = function (stackTrace) {
  4446. return collection_1.isListLikeIterable(stackTrace) ? stackTrace.join("\n\n-----async gap-----\n") :
  4447. stackTrace.toString();
  4448. };
  4449. /** @internal */
  4450. ExceptionHandler.prototype._findContext = function (exception) {
  4451. try {
  4452. if (!(exception instanceof exceptions_1.WrappedException))
  4453. return null;
  4454. return lang_1.isPresent(exception.context) ? exception.context :
  4455. this._findContext(exception.originalException);
  4456. }
  4457. catch (e) {
  4458. // exception.context can throw an exception. if it happens, we ignore the context.
  4459. return null;
  4460. }
  4461. };
  4462. /** @internal */
  4463. ExceptionHandler.prototype._findOriginalException = function (exception) {
  4464. if (!(exception instanceof exceptions_1.WrappedException))
  4465. return null;
  4466. var e = exception.originalException;
  4467. while (e instanceof exceptions_1.WrappedException && lang_1.isPresent(e.originalException)) {
  4468. e = e.originalException;
  4469. }
  4470. return e;
  4471. };
  4472. /** @internal */
  4473. ExceptionHandler.prototype._findOriginalStack = function (exception) {
  4474. if (!(exception instanceof exceptions_1.WrappedException))
  4475. return null;
  4476. var e = exception;
  4477. var stack = exception.originalStack;
  4478. while (e instanceof exceptions_1.WrappedException && lang_1.isPresent(e.originalException)) {
  4479. e = e.originalException;
  4480. if (e instanceof exceptions_1.WrappedException && lang_1.isPresent(e.originalException)) {
  4481. stack = e.originalStack;
  4482. }
  4483. }
  4484. return stack;
  4485. };
  4486. return ExceptionHandler;
  4487. })();
  4488. exports.ExceptionHandler = ExceptionHandler;
  4489. /***/ },
  4490. /* 16 */
  4491. /***/ function(module, exports, __webpack_require__) {
  4492. var reflector_1 = __webpack_require__(17);
  4493. var reflector_2 = __webpack_require__(17);
  4494. exports.Reflector = reflector_2.Reflector;
  4495. exports.ReflectionInfo = reflector_2.ReflectionInfo;
  4496. var reflection_capabilities_1 = __webpack_require__(18);
  4497. /**
  4498. * The {@link Reflector} used internally in Angular to access metadata
  4499. * about symbols.
  4500. */
  4501. exports.reflector = new reflector_1.Reflector(new reflection_capabilities_1.ReflectionCapabilities());
  4502. /***/ },
  4503. /* 17 */
  4504. /***/ function(module, exports, __webpack_require__) {
  4505. var lang_1 = __webpack_require__(5);
  4506. var exceptions_1 = __webpack_require__(14);
  4507. var collection_1 = __webpack_require__(12);
  4508. /**
  4509. * Reflective information about a symbol, including annotations, interfaces, and other metadata.
  4510. */
  4511. var ReflectionInfo = (function () {
  4512. function ReflectionInfo(annotations, parameters, factory, interfaces, propMetadata) {
  4513. this.annotations = annotations;
  4514. this.parameters = parameters;
  4515. this.factory = factory;
  4516. this.interfaces = interfaces;
  4517. this.propMetadata = propMetadata;
  4518. }
  4519. return ReflectionInfo;
  4520. })();
  4521. exports.ReflectionInfo = ReflectionInfo;
  4522. /**
  4523. * Provides access to reflection data about symbols. Used internally by Angular
  4524. * to power dependency injection and compilation.
  4525. */
  4526. var Reflector = (function () {
  4527. function Reflector(reflectionCapabilities) {
  4528. /** @internal */
  4529. this._injectableInfo = new collection_1.Map();
  4530. /** @internal */
  4531. this._getters = new collection_1.Map();
  4532. /** @internal */
  4533. this._setters = new collection_1.Map();
  4534. /** @internal */
  4535. this._methods = new collection_1.Map();
  4536. this._usedKeys = null;
  4537. this.reflectionCapabilities = reflectionCapabilities;
  4538. }
  4539. Reflector.prototype.isReflectionEnabled = function () { return this.reflectionCapabilities.isReflectionEnabled(); };
  4540. /**
  4541. * Causes `this` reflector to track keys used to access
  4542. * {@link ReflectionInfo} objects.
  4543. */
  4544. Reflector.prototype.trackUsage = function () { this._usedKeys = new collection_1.Set(); };
  4545. /**
  4546. * Lists types for which reflection information was not requested since
  4547. * {@link #trackUsage} was called. This list could later be audited as
  4548. * potential dead code.
  4549. */
  4550. Reflector.prototype.listUnusedKeys = function () {
  4551. var _this = this;
  4552. if (this._usedKeys == null) {
  4553. throw new exceptions_1.BaseException('Usage tracking is disabled');
  4554. }
  4555. var allTypes = collection_1.MapWrapper.keys(this._injectableInfo);
  4556. return allTypes.filter(function (key) { return !collection_1.SetWrapper.has(_this._usedKeys, key); });
  4557. };
  4558. Reflector.prototype.registerFunction = function (func, funcInfo) {
  4559. this._injectableInfo.set(func, funcInfo);
  4560. };
  4561. Reflector.prototype.registerType = function (type, typeInfo) {
  4562. this._injectableInfo.set(type, typeInfo);
  4563. };
  4564. Reflector.prototype.registerGetters = function (getters) { _mergeMaps(this._getters, getters); };
  4565. Reflector.prototype.registerSetters = function (setters) { _mergeMaps(this._setters, setters); };
  4566. Reflector.prototype.registerMethods = function (methods) { _mergeMaps(this._methods, methods); };
  4567. Reflector.prototype.factory = function (type) {
  4568. if (this._containsReflectionInfo(type)) {
  4569. var res = this._getReflectionInfo(type).factory;
  4570. return lang_1.isPresent(res) ? res : null;
  4571. }
  4572. else {
  4573. return this.reflectionCapabilities.factory(type);
  4574. }
  4575. };
  4576. Reflector.prototype.parameters = function (typeOrFunc) {
  4577. if (this._injectableInfo.has(typeOrFunc)) {
  4578. var res = this._getReflectionInfo(typeOrFunc).parameters;
  4579. return lang_1.isPresent(res) ? res : [];
  4580. }
  4581. else {
  4582. return this.reflectionCapabilities.parameters(typeOrFunc);
  4583. }
  4584. };
  4585. Reflector.prototype.annotations = function (typeOrFunc) {
  4586. if (this._injectableInfo.has(typeOrFunc)) {
  4587. var res = this._getReflectionInfo(typeOrFunc).annotations;
  4588. return lang_1.isPresent(res) ? res : [];
  4589. }
  4590. else {
  4591. return this.reflectionCapabilities.annotations(typeOrFunc);
  4592. }
  4593. };
  4594. Reflector.prototype.propMetadata = function (typeOrFunc) {
  4595. if (this._injectableInfo.has(typeOrFunc)) {
  4596. var res = this._getReflectionInfo(typeOrFunc).propMetadata;
  4597. return lang_1.isPresent(res) ? res : {};
  4598. }
  4599. else {
  4600. return this.reflectionCapabilities.propMetadata(typeOrFunc);
  4601. }
  4602. };
  4603. Reflector.prototype.interfaces = function (type) {
  4604. if (this._injectableInfo.has(type)) {
  4605. var res = this._getReflectionInfo(type).interfaces;
  4606. return lang_1.isPresent(res) ? res : [];
  4607. }
  4608. else {
  4609. return this.reflectionCapabilities.interfaces(type);
  4610. }
  4611. };
  4612. Reflector.prototype.getter = function (name) {
  4613. if (this._getters.has(name)) {
  4614. return this._getters.get(name);
  4615. }
  4616. else {
  4617. return this.reflectionCapabilities.getter(name);
  4618. }
  4619. };
  4620. Reflector.prototype.setter = function (name) {
  4621. if (this._setters.has(name)) {
  4622. return this._setters.get(name);
  4623. }
  4624. else {
  4625. return this.reflectionCapabilities.setter(name);
  4626. }
  4627. };
  4628. Reflector.prototype.method = function (name) {
  4629. if (this._methods.has(name)) {
  4630. return this._methods.get(name);
  4631. }
  4632. else {
  4633. return this.reflectionCapabilities.method(name);
  4634. }
  4635. };
  4636. /** @internal */
  4637. Reflector.prototype._getReflectionInfo = function (typeOrFunc) {
  4638. if (lang_1.isPresent(this._usedKeys)) {
  4639. this._usedKeys.add(typeOrFunc);
  4640. }
  4641. return this._injectableInfo.get(typeOrFunc);
  4642. };
  4643. /** @internal */
  4644. Reflector.prototype._containsReflectionInfo = function (typeOrFunc) { return this._injectableInfo.has(typeOrFunc); };
  4645. Reflector.prototype.importUri = function (type) { return this.reflectionCapabilities.importUri(type); };
  4646. return Reflector;
  4647. })();
  4648. exports.Reflector = Reflector;
  4649. function _mergeMaps(target, config) {
  4650. collection_1.StringMapWrapper.forEach(config, function (v, k) { return target.set(k, v); });
  4651. }
  4652. /***/ },
  4653. /* 18 */
  4654. /***/ function(module, exports, __webpack_require__) {
  4655. var lang_1 = __webpack_require__(5);
  4656. var exceptions_1 = __webpack_require__(14);
  4657. var ReflectionCapabilities = (function () {
  4658. function ReflectionCapabilities(reflect) {
  4659. this._reflect = lang_1.isPresent(reflect) ? reflect : lang_1.global.Reflect;
  4660. }
  4661. ReflectionCapabilities.prototype.isReflectionEnabled = function () { return true; };
  4662. ReflectionCapabilities.prototype.factory = function (t) {
  4663. switch (t.length) {
  4664. case 0:
  4665. return function () { return new t(); };
  4666. case 1:
  4667. return function (a1) { return new t(a1); };
  4668. case 2:
  4669. return function (a1, a2) { return new t(a1, a2); };
  4670. case 3:
  4671. return function (a1, a2, a3) { return new t(a1, a2, a3); };
  4672. case 4:
  4673. return function (a1, a2, a3, a4) { return new t(a1, a2, a3, a4); };
  4674. case 5:
  4675. return function (a1, a2, a3, a4, a5) { return new t(a1, a2, a3, a4, a5); };
  4676. case 6:
  4677. return function (a1, a2, a3, a4, a5, a6) { return new t(a1, a2, a3, a4, a5, a6); };
  4678. case 7:
  4679. return function (a1, a2, a3, a4, a5, a6, a7) { return new t(a1, a2, a3, a4, a5, a6, a7); };
  4680. case 8:
  4681. return function (a1, a2, a3, a4, a5, a6, a7, a8) { return new t(a1, a2, a3, a4, a5, a6, a7, a8); };
  4682. case 9:
  4683. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9) { return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9); };
  4684. case 10:
  4685. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
  4686. return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
  4687. };
  4688. case 11:
  4689. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) {
  4690. return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
  4691. };
  4692. case 12:
  4693. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) {
  4694. return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12);
  4695. };
  4696. case 13:
  4697. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) {
  4698. return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13);
  4699. };
  4700. case 14:
  4701. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) {
  4702. return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14);
  4703. };
  4704. case 15:
  4705. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) {
  4706. return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15);
  4707. };
  4708. case 16:
  4709. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) {
  4710. return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16);
  4711. };
  4712. case 17:
  4713. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) {
  4714. return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17);
  4715. };
  4716. case 18:
  4717. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) {
  4718. return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18);
  4719. };
  4720. case 19:
  4721. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) {
  4722. return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19);
  4723. };
  4724. case 20:
  4725. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) {
  4726. return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
  4727. };
  4728. }
  4729. ;
  4730. throw new Error("Cannot create a factory for '" + lang_1.stringify(t) + "' because its constructor has more than 20 arguments");
  4731. };
  4732. /** @internal */
  4733. ReflectionCapabilities.prototype._zipTypesAndAnnotaions = function (paramTypes, paramAnnotations) {
  4734. var result;
  4735. if (typeof paramTypes === 'undefined') {
  4736. result = new Array(paramAnnotations.length);
  4737. }
  4738. else {
  4739. result = new Array(paramTypes.length);
  4740. }
  4741. for (var i = 0; i < result.length; i++) {
  4742. // TS outputs Object for parameters without types, while Traceur omits
  4743. // the annotations. For now we preserve the Traceur behavior to aid
  4744. // migration, but this can be revisited.
  4745. if (typeof paramTypes === 'undefined') {
  4746. result[i] = [];
  4747. }
  4748. else if (paramTypes[i] != Object) {
  4749. result[i] = [paramTypes[i]];
  4750. }
  4751. else {
  4752. result[i] = [];
  4753. }
  4754. if (lang_1.isPresent(paramAnnotations) && lang_1.isPresent(paramAnnotations[i])) {
  4755. result[i] = result[i].concat(paramAnnotations[i]);
  4756. }
  4757. }
  4758. return result;
  4759. };
  4760. ReflectionCapabilities.prototype.parameters = function (typeOrFunc) {
  4761. // Prefer the direct API.
  4762. if (lang_1.isPresent(typeOrFunc.parameters)) {
  4763. return typeOrFunc.parameters;
  4764. }
  4765. if (lang_1.isPresent(this._reflect) && lang_1.isPresent(this._reflect.getMetadata)) {
  4766. var paramAnnotations = this._reflect.getMetadata('parameters', typeOrFunc);
  4767. var paramTypes = this._reflect.getMetadata('design:paramtypes', typeOrFunc);
  4768. if (lang_1.isPresent(paramTypes) || lang_1.isPresent(paramAnnotations)) {
  4769. return this._zipTypesAndAnnotaions(paramTypes, paramAnnotations);
  4770. }
  4771. }
  4772. // The array has to be filled with `undefined` because holes would be skipped by `some`
  4773. var parameters = new Array(typeOrFunc.length);
  4774. parameters.fill(undefined);
  4775. return parameters;
  4776. };
  4777. ReflectionCapabilities.prototype.annotations = function (typeOrFunc) {
  4778. // Prefer the direct API.
  4779. if (lang_1.isPresent(typeOrFunc.annotations)) {
  4780. var annotations = typeOrFunc.annotations;
  4781. if (lang_1.isFunction(annotations) && annotations.annotations) {
  4782. annotations = annotations.annotations;
  4783. }
  4784. return annotations;
  4785. }
  4786. if (lang_1.isPresent(this._reflect) && lang_1.isPresent(this._reflect.getMetadata)) {
  4787. var annotations = this._reflect.getMetadata('annotations', typeOrFunc);
  4788. if (lang_1.isPresent(annotations))
  4789. return annotations;
  4790. }
  4791. return [];
  4792. };
  4793. ReflectionCapabilities.prototype.propMetadata = function (typeOrFunc) {
  4794. // Prefer the direct API.
  4795. if (lang_1.isPresent(typeOrFunc.propMetadata)) {
  4796. var propMetadata = typeOrFunc.propMetadata;
  4797. if (lang_1.isFunction(propMetadata) && propMetadata.propMetadata) {
  4798. propMetadata = propMetadata.propMetadata;
  4799. }
  4800. return propMetadata;
  4801. }
  4802. if (lang_1.isPresent(this._reflect) && lang_1.isPresent(this._reflect.getMetadata)) {
  4803. var propMetadata = this._reflect.getMetadata('propMetadata', typeOrFunc);
  4804. if (lang_1.isPresent(propMetadata))
  4805. return propMetadata;
  4806. }
  4807. return {};
  4808. };
  4809. ReflectionCapabilities.prototype.interfaces = function (type) {
  4810. throw new exceptions_1.BaseException("JavaScript does not support interfaces");
  4811. };
  4812. ReflectionCapabilities.prototype.getter = function (name) { return new Function('o', 'return o.' + name + ';'); };
  4813. ReflectionCapabilities.prototype.setter = function (name) {
  4814. return new Function('o', 'v', 'return o.' + name + ' = v;');
  4815. };
  4816. ReflectionCapabilities.prototype.method = function (name) {
  4817. var functionBody = "if (!o." + name + ") throw new Error('\"" + name + "\" is undefined');\n return o." + name + ".apply(o, args);";
  4818. return new Function('o', 'args', functionBody);
  4819. };
  4820. // There is not a concept of import uri in Js, but this is useful in developing Dart applications.
  4821. ReflectionCapabilities.prototype.importUri = function (type) { return './'; };
  4822. return ReflectionCapabilities;
  4823. })();
  4824. exports.ReflectionCapabilities = ReflectionCapabilities;
  4825. /***/ },
  4826. /* 19 */
  4827. /***/ function(module, exports, __webpack_require__) {
  4828. var lang_1 = __webpack_require__(5);
  4829. var exceptions_1 = __webpack_require__(14);
  4830. var type_literal_1 = __webpack_require__(20);
  4831. var forward_ref_1 = __webpack_require__(10);
  4832. var type_literal_2 = __webpack_require__(20);
  4833. exports.TypeLiteral = type_literal_2.TypeLiteral;
  4834. /**
  4835. * A unique object used for retrieving items from the {@link Injector}.
  4836. *
  4837. * Keys have:
  4838. * - a system-wide unique `id`.
  4839. * - a `token`.
  4840. *
  4841. * `Key` is used internally by {@link Injector} because its system-wide unique `id` allows the
  4842. * injector to store created objects in a more efficient way.
  4843. *
  4844. * `Key` should not be created directly. {@link Injector} creates keys automatically when resolving
  4845. * providers.
  4846. */
  4847. var Key = (function () {
  4848. /**
  4849. * Private
  4850. */
  4851. function Key(token, id) {
  4852. this.token = token;
  4853. this.id = id;
  4854. if (lang_1.isBlank(token)) {
  4855. throw new exceptions_1.BaseException('Token must be defined!');
  4856. }
  4857. }
  4858. Object.defineProperty(Key.prototype, "displayName", {
  4859. /**
  4860. * Returns a stringified token.
  4861. */
  4862. get: function () { return lang_1.stringify(this.token); },
  4863. enumerable: true,
  4864. configurable: true
  4865. });
  4866. /**
  4867. * Retrieves a `Key` for a token.
  4868. */
  4869. Key.get = function (token) { return _globalKeyRegistry.get(forward_ref_1.resolveForwardRef(token)); };
  4870. Object.defineProperty(Key, "numberOfKeys", {
  4871. /**
  4872. * @returns the number of keys registered in the system.
  4873. */
  4874. get: function () { return _globalKeyRegistry.numberOfKeys; },
  4875. enumerable: true,
  4876. configurable: true
  4877. });
  4878. return Key;
  4879. })();
  4880. exports.Key = Key;
  4881. /**
  4882. * @internal
  4883. */
  4884. var KeyRegistry = (function () {
  4885. function KeyRegistry() {
  4886. this._allKeys = new Map();
  4887. }
  4888. KeyRegistry.prototype.get = function (token) {
  4889. if (token instanceof Key)
  4890. return token;
  4891. // TODO: workaround for https://github.com/Microsoft/TypeScript/issues/3123
  4892. var theToken = token;
  4893. if (token instanceof type_literal_1.TypeLiteral) {
  4894. theToken = token.type;
  4895. }
  4896. token = theToken;
  4897. if (this._allKeys.has(token)) {
  4898. return this._allKeys.get(token);
  4899. }
  4900. var newKey = new Key(token, Key.numberOfKeys);
  4901. this._allKeys.set(token, newKey);
  4902. return newKey;
  4903. };
  4904. Object.defineProperty(KeyRegistry.prototype, "numberOfKeys", {
  4905. get: function () { return this._allKeys.size; },
  4906. enumerable: true,
  4907. configurable: true
  4908. });
  4909. return KeyRegistry;
  4910. })();
  4911. exports.KeyRegistry = KeyRegistry;
  4912. var _globalKeyRegistry = new KeyRegistry();
  4913. /***/ },
  4914. /* 20 */
  4915. /***/ function(module, exports) {
  4916. /**
  4917. * Type literals is a Dart-only feature. This is here only so we can x-compile
  4918. * to multiple languages.
  4919. */
  4920. var TypeLiteral = (function () {
  4921. function TypeLiteral() {
  4922. }
  4923. Object.defineProperty(TypeLiteral.prototype, "type", {
  4924. get: function () { throw new Error("Type literals are only supported in Dart"); },
  4925. enumerable: true,
  4926. configurable: true
  4927. });
  4928. return TypeLiteral;
  4929. })();
  4930. exports.TypeLiteral = TypeLiteral;
  4931. /***/ },
  4932. /* 21 */
  4933. /***/ function(module, exports, __webpack_require__) {
  4934. var __extends = (this && this.__extends) || function (d, b) {
  4935. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4936. function __() { this.constructor = d; }
  4937. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4938. };
  4939. var collection_1 = __webpack_require__(12);
  4940. var lang_1 = __webpack_require__(5);
  4941. var exceptions_1 = __webpack_require__(14);
  4942. function findFirstClosedCycle(keys) {
  4943. var res = [];
  4944. for (var i = 0; i < keys.length; ++i) {
  4945. if (collection_1.ListWrapper.contains(res, keys[i])) {
  4946. res.push(keys[i]);
  4947. return res;
  4948. }
  4949. else {
  4950. res.push(keys[i]);
  4951. }
  4952. }
  4953. return res;
  4954. }
  4955. function constructResolvingPath(keys) {
  4956. if (keys.length > 1) {
  4957. var reversed = findFirstClosedCycle(collection_1.ListWrapper.reversed(keys));
  4958. var tokenStrs = reversed.map(function (k) { return lang_1.stringify(k.token); });
  4959. return " (" + tokenStrs.join(' -> ') + ")";
  4960. }
  4961. else {
  4962. return "";
  4963. }
  4964. }
  4965. /**
  4966. * Base class for all errors arising from misconfigured providers.
  4967. */
  4968. var AbstractProviderError = (function (_super) {
  4969. __extends(AbstractProviderError, _super);
  4970. function AbstractProviderError(injector, key, constructResolvingMessage) {
  4971. _super.call(this, "DI Exception");
  4972. this.keys = [key];
  4973. this.injectors = [injector];
  4974. this.constructResolvingMessage = constructResolvingMessage;
  4975. this.message = this.constructResolvingMessage(this.keys);
  4976. }
  4977. AbstractProviderError.prototype.addKey = function (injector, key) {
  4978. this.injectors.push(injector);
  4979. this.keys.push(key);
  4980. this.message = this.constructResolvingMessage(this.keys);
  4981. };
  4982. Object.defineProperty(AbstractProviderError.prototype, "context", {
  4983. get: function () { return this.injectors[this.injectors.length - 1].debugContext(); },
  4984. enumerable: true,
  4985. configurable: true
  4986. });
  4987. return AbstractProviderError;
  4988. })(exceptions_1.BaseException);
  4989. exports.AbstractProviderError = AbstractProviderError;
  4990. /**
  4991. * Thrown when trying to retrieve a dependency by `Key` from {@link Injector}, but the
  4992. * {@link Injector} does not have a {@link Provider} for {@link Key}.
  4993. *
  4994. * ### Example ([live demo](http://plnkr.co/edit/vq8D3FRB9aGbnWJqtEPE?p=preview))
  4995. *
  4996. * ```typescript
  4997. * class A {
  4998. * constructor(b:B) {}
  4999. * }
  5000. *
  5001. * expect(() => Injector.resolveAndCreate([A])).toThrowError();
  5002. * ```
  5003. */
  5004. var NoProviderError = (function (_super) {
  5005. __extends(NoProviderError, _super);
  5006. function NoProviderError(injector, key) {
  5007. _super.call(this, injector, key, function (keys) {
  5008. var first = lang_1.stringify(collection_1.ListWrapper.first(keys).token);
  5009. return "No provider for " + first + "!" + constructResolvingPath(keys);
  5010. });
  5011. }
  5012. return NoProviderError;
  5013. })(AbstractProviderError);
  5014. exports.NoProviderError = NoProviderError;
  5015. /**
  5016. * Thrown when dependencies form a cycle.
  5017. *
  5018. * ### Example ([live demo](http://plnkr.co/edit/wYQdNos0Tzql3ei1EV9j?p=info))
  5019. *
  5020. * ```typescript
  5021. * var injector = Injector.resolveAndCreate([
  5022. * provide("one", {useFactory: (two) => "two", deps: [[new Inject("two")]]}),
  5023. * provide("two", {useFactory: (one) => "one", deps: [[new Inject("one")]]})
  5024. * ]);
  5025. *
  5026. * expect(() => injector.get("one")).toThrowError();
  5027. * ```
  5028. *
  5029. * Retrieving `A` or `B` throws a `CyclicDependencyError` as the graph above cannot be constructed.
  5030. */
  5031. var CyclicDependencyError = (function (_super) {
  5032. __extends(CyclicDependencyError, _super);
  5033. function CyclicDependencyError(injector, key) {
  5034. _super.call(this, injector, key, function (keys) {
  5035. return "Cannot instantiate cyclic dependency!" + constructResolvingPath(keys);
  5036. });
  5037. }
  5038. return CyclicDependencyError;
  5039. })(AbstractProviderError);
  5040. exports.CyclicDependencyError = CyclicDependencyError;
  5041. /**
  5042. * Thrown when a constructing type returns with an Error.
  5043. *
  5044. * The `InstantiationError` class contains the original error plus the dependency graph which caused
  5045. * this object to be instantiated.
  5046. *
  5047. * ### Example ([live demo](http://plnkr.co/edit/7aWYdcqTQsP0eNqEdUAf?p=preview))
  5048. *
  5049. * ```typescript
  5050. * class A {
  5051. * constructor() {
  5052. * throw new Error('message');
  5053. * }
  5054. * }
  5055. *
  5056. * var injector = Injector.resolveAndCreate([A]);
  5057. * try {
  5058. * injector.get(A);
  5059. * } catch (e) {
  5060. * expect(e instanceof InstantiationError).toBe(true);
  5061. * expect(e.originalException.message).toEqual("message");
  5062. * expect(e.originalStack).toBeDefined();
  5063. * }
  5064. * ```
  5065. */
  5066. var InstantiationError = (function (_super) {
  5067. __extends(InstantiationError, _super);
  5068. function InstantiationError(injector, originalException, originalStack, key) {
  5069. _super.call(this, "DI Exception", originalException, originalStack, null);
  5070. this.keys = [key];
  5071. this.injectors = [injector];
  5072. }
  5073. InstantiationError.prototype.addKey = function (injector, key) {
  5074. this.injectors.push(injector);
  5075. this.keys.push(key);
  5076. };
  5077. Object.defineProperty(InstantiationError.prototype, "wrapperMessage", {
  5078. get: function () {
  5079. var first = lang_1.stringify(collection_1.ListWrapper.first(this.keys).token);
  5080. return "Error during instantiation of " + first + "!" + constructResolvingPath(this.keys) + ".";
  5081. },
  5082. enumerable: true,
  5083. configurable: true
  5084. });
  5085. Object.defineProperty(InstantiationError.prototype, "causeKey", {
  5086. get: function () { return this.keys[0]; },
  5087. enumerable: true,
  5088. configurable: true
  5089. });
  5090. Object.defineProperty(InstantiationError.prototype, "context", {
  5091. get: function () { return this.injectors[this.injectors.length - 1].debugContext(); },
  5092. enumerable: true,
  5093. configurable: true
  5094. });
  5095. return InstantiationError;
  5096. })(exceptions_1.WrappedException);
  5097. exports.InstantiationError = InstantiationError;
  5098. /**
  5099. * Thrown when an object other then {@link Provider} (or `Type`) is passed to {@link Injector}
  5100. * creation.
  5101. *
  5102. * ### Example ([live demo](http://plnkr.co/edit/YatCFbPAMCL0JSSQ4mvH?p=preview))
  5103. *
  5104. * ```typescript
  5105. * expect(() => Injector.resolveAndCreate(["not a type"])).toThrowError();
  5106. * ```
  5107. */
  5108. var InvalidProviderError = (function (_super) {
  5109. __extends(InvalidProviderError, _super);
  5110. function InvalidProviderError(provider) {
  5111. _super.call(this, "Invalid provider - only instances of Provider and Type are allowed, got: " +
  5112. provider.toString());
  5113. }
  5114. return InvalidProviderError;
  5115. })(exceptions_1.BaseException);
  5116. exports.InvalidProviderError = InvalidProviderError;
  5117. /**
  5118. * Thrown when the class has no annotation information.
  5119. *
  5120. * Lack of annotation information prevents the {@link Injector} from determining which dependencies
  5121. * need to be injected into the constructor.
  5122. *
  5123. * ### Example ([live demo](http://plnkr.co/edit/rHnZtlNS7vJOPQ6pcVkm?p=preview))
  5124. *
  5125. * ```typescript
  5126. * class A {
  5127. * constructor(b) {}
  5128. * }
  5129. *
  5130. * expect(() => Injector.resolveAndCreate([A])).toThrowError();
  5131. * ```
  5132. *
  5133. * This error is also thrown when the class not marked with {@link Injectable} has parameter types.
  5134. *
  5135. * ```typescript
  5136. * class B {}
  5137. *
  5138. * class A {
  5139. * constructor(b:B) {} // no information about the parameter types of A is available at runtime.
  5140. * }
  5141. *
  5142. * expect(() => Injector.resolveAndCreate([A,B])).toThrowError();
  5143. * ```
  5144. */
  5145. var NoAnnotationError = (function (_super) {
  5146. __extends(NoAnnotationError, _super);
  5147. function NoAnnotationError(typeOrFunc, params) {
  5148. _super.call(this, NoAnnotationError._genMessage(typeOrFunc, params));
  5149. }
  5150. NoAnnotationError._genMessage = function (typeOrFunc, params) {
  5151. var signature = [];
  5152. for (var i = 0, ii = params.length; i < ii; i++) {
  5153. var parameter = params[i];
  5154. if (lang_1.isBlank(parameter) || parameter.length == 0) {
  5155. signature.push('?');
  5156. }
  5157. else {
  5158. signature.push(parameter.map(lang_1.stringify).join(' '));
  5159. }
  5160. }
  5161. return "Cannot resolve all parameters for " + lang_1.stringify(typeOrFunc) + "(" +
  5162. signature.join(', ') + "). " + 'Make sure they all have valid type or annotations.';
  5163. };
  5164. return NoAnnotationError;
  5165. })(exceptions_1.BaseException);
  5166. exports.NoAnnotationError = NoAnnotationError;
  5167. /**
  5168. * Thrown when getting an object by index.
  5169. *
  5170. * ### Example ([live demo](http://plnkr.co/edit/bRs0SX2OTQiJzqvjgl8P?p=preview))
  5171. *
  5172. * ```typescript
  5173. * class A {}
  5174. *
  5175. * var injector = Injector.resolveAndCreate([A]);
  5176. *
  5177. * expect(() => injector.getAt(100)).toThrowError();
  5178. * ```
  5179. */
  5180. var OutOfBoundsError = (function (_super) {
  5181. __extends(OutOfBoundsError, _super);
  5182. function OutOfBoundsError(index) {
  5183. _super.call(this, "Index " + index + " is out-of-bounds.");
  5184. }
  5185. return OutOfBoundsError;
  5186. })(exceptions_1.BaseException);
  5187. exports.OutOfBoundsError = OutOfBoundsError;
  5188. // TODO: add a working example after alpha38 is released
  5189. /**
  5190. * Thrown when a multi provider and a regular provider are bound to the same token.
  5191. *
  5192. * ### Example
  5193. *
  5194. * ```typescript
  5195. * expect(() => Injector.resolveAndCreate([
  5196. * new Provider("Strings", {useValue: "string1", multi: true}),
  5197. * new Provider("Strings", {useValue: "string2", multi: false})
  5198. * ])).toThrowError();
  5199. * ```
  5200. */
  5201. var MixingMultiProvidersWithRegularProvidersError = (function (_super) {
  5202. __extends(MixingMultiProvidersWithRegularProvidersError, _super);
  5203. function MixingMultiProvidersWithRegularProvidersError(provider1, provider2) {
  5204. _super.call(this, "Cannot mix multi providers and regular providers, got: " + provider1.toString() + " " +
  5205. provider2.toString());
  5206. }
  5207. return MixingMultiProvidersWithRegularProvidersError;
  5208. })(exceptions_1.BaseException);
  5209. exports.MixingMultiProvidersWithRegularProvidersError = MixingMultiProvidersWithRegularProvidersError;
  5210. /***/ },
  5211. /* 22 */
  5212. /***/ function(module, exports, __webpack_require__) {
  5213. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  5214. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  5215. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  5216. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5217. return c > 3 && r && Object.defineProperty(target, key, r), r;
  5218. };
  5219. var __metadata = (this && this.__metadata) || function (k, v) {
  5220. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  5221. };
  5222. var lang_1 = __webpack_require__(5);
  5223. /**
  5224. * Creates a token that can be used in a DI Provider.
  5225. *
  5226. * ### Example ([live demo](http://plnkr.co/edit/Ys9ezXpj2Mnoy3Uc8KBp?p=preview))
  5227. *
  5228. * ```typescript
  5229. * var t = new OpaqueToken("value");
  5230. *
  5231. * var injector = Injector.resolveAndCreate([
  5232. * provide(t, {useValue: "providedValue"})
  5233. * ]);
  5234. *
  5235. * expect(injector.get(t)).toEqual("bindingValue");
  5236. * ```
  5237. *
  5238. * Using an `OpaqueToken` is preferable to using strings as tokens because of possible collisions
  5239. * caused by multiple providers using the same string as two different tokens.
  5240. *
  5241. * Using an `OpaqueToken` is preferable to using an `Object` as tokens because it provides better
  5242. * error messages.
  5243. */
  5244. var OpaqueToken = (function () {
  5245. function OpaqueToken(_desc) {
  5246. this._desc = _desc;
  5247. }
  5248. OpaqueToken.prototype.toString = function () { return "Token " + this._desc; };
  5249. OpaqueToken = __decorate([
  5250. lang_1.CONST(),
  5251. __metadata('design:paramtypes', [String])
  5252. ], OpaqueToken);
  5253. return OpaqueToken;
  5254. })();
  5255. exports.OpaqueToken = OpaqueToken;
  5256. /***/ },
  5257. /* 23 */
  5258. /***/ function(module, exports, __webpack_require__) {
  5259. var __extends = (this && this.__extends) || function (d, b) {
  5260. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  5261. function __() { this.constructor = d; }
  5262. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5263. };
  5264. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  5265. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  5266. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  5267. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5268. return c > 3 && r && Object.defineProperty(target, key, r), r;
  5269. };
  5270. var __metadata = (this && this.__metadata) || function (k, v) {
  5271. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  5272. };
  5273. var lang_1 = __webpack_require__(5);
  5274. var metadata_1 = __webpack_require__(7);
  5275. var change_detection_1 = __webpack_require__(24);
  5276. /**
  5277. * Directives allow you to attach behavior to elements in the DOM.
  5278. *
  5279. * {@link DirectiveMetadata}s with an embedded view are called {@link ComponentMetadata}s.
  5280. *
  5281. * A directive consists of a single directive annotation and a controller class. When the
  5282. * directive's `selector` matches
  5283. * elements in the DOM, the following steps occur:
  5284. *
  5285. * 1. For each directive, the `ElementInjector` attempts to resolve the directive's constructor
  5286. * arguments.
  5287. * 2. Angular instantiates directives for each matched element using `ElementInjector` in a
  5288. * depth-first order,
  5289. * as declared in the HTML.
  5290. *
  5291. * ## Understanding How Injection Works
  5292. *
  5293. * There are three stages of injection resolution.
  5294. * - *Pre-existing Injectors*:
  5295. * - The terminal {@link Injector} cannot resolve dependencies. It either throws an error or, if
  5296. * the dependency was
  5297. * specified as `@Optional`, returns `null`.
  5298. * - The platform injector resolves browser singleton resources, such as: cookies, title,
  5299. * location, and others.
  5300. * - *Component Injectors*: Each component instance has its own {@link Injector}, and they follow
  5301. * the same parent-child hierarchy
  5302. * as the component instances in the DOM.
  5303. * - *Element Injectors*: Each component instance has a Shadow DOM. Within the Shadow DOM each
  5304. * element has an `ElementInjector`
  5305. * which follow the same parent-child hierarchy as the DOM elements themselves.
  5306. *
  5307. * When a template is instantiated, it also must instantiate the corresponding directives in a
  5308. * depth-first order. The
  5309. * current `ElementInjector` resolves the constructor dependencies for each directive.
  5310. *
  5311. * Angular then resolves dependencies as follows, according to the order in which they appear in the
  5312. * {@link ViewMetadata}:
  5313. *
  5314. * 1. Dependencies on the current element
  5315. * 2. Dependencies on element injectors and their parents until it encounters a Shadow DOM boundary
  5316. * 3. Dependencies on component injectors and their parents until it encounters the root component
  5317. * 4. Dependencies on pre-existing injectors
  5318. *
  5319. *
  5320. * The `ElementInjector` can inject other directives, element-specific special objects, or it can
  5321. * delegate to the parent
  5322. * injector.
  5323. *
  5324. * To inject other directives, declare the constructor parameter as:
  5325. * - `directive:DirectiveType`: a directive on the current element only
  5326. * - `@Host() directive:DirectiveType`: any directive that matches the type between the current
  5327. * element and the
  5328. * Shadow DOM root.
  5329. * - `@Query(DirectiveType) query:QueryList<DirectiveType>`: A live collection of direct child
  5330. * directives.
  5331. * - `@QueryDescendants(DirectiveType) query:QueryList<DirectiveType>`: A live collection of any
  5332. * child directives.
  5333. *
  5334. * To inject element-specific special objects, declare the constructor parameter as:
  5335. * - `element: ElementRef` to obtain a reference to logical element in the view.
  5336. * - `viewContainer: ViewContainerRef` to control child template instantiation, for
  5337. * {@link DirectiveMetadata} directives only
  5338. * - `bindingPropagation: BindingPropagation` to control change detection in a more granular way.
  5339. *
  5340. * ### Example
  5341. *
  5342. * The following example demonstrates how dependency injection resolves constructor arguments in
  5343. * practice.
  5344. *
  5345. *
  5346. * Assume this HTML template:
  5347. *
  5348. * ```
  5349. * <div dependency="1">
  5350. * <div dependency="2">
  5351. * <div dependency="3" my-directive>
  5352. * <div dependency="4">
  5353. * <div dependency="5"></div>
  5354. * </div>
  5355. * <div dependency="6"></div>
  5356. * </div>
  5357. * </div>
  5358. * </div>
  5359. * ```
  5360. *
  5361. * With the following `dependency` decorator and `SomeService` injectable class.
  5362. *
  5363. * ```
  5364. * @Injectable()
  5365. * class SomeService {
  5366. * }
  5367. *
  5368. * @Directive({
  5369. * selector: '[dependency]',
  5370. * inputs: [
  5371. * 'id: dependency'
  5372. * ]
  5373. * })
  5374. * class Dependency {
  5375. * id:string;
  5376. * }
  5377. * ```
  5378. *
  5379. * Let's step through the different ways in which `MyDirective` could be declared...
  5380. *
  5381. *
  5382. * ### No injection
  5383. *
  5384. * Here the constructor is declared with no arguments, therefore nothing is injected into
  5385. * `MyDirective`.
  5386. *
  5387. * ```
  5388. * @Directive({ selector: '[my-directive]' })
  5389. * class MyDirective {
  5390. * constructor() {
  5391. * }
  5392. * }
  5393. * ```
  5394. *
  5395. * This directive would be instantiated with no dependencies.
  5396. *
  5397. *
  5398. * ### Component-level injection
  5399. *
  5400. * Directives can inject any injectable instance from the closest component injector or any of its
  5401. * parents.
  5402. *
  5403. * Here, the constructor declares a parameter, `someService`, and injects the `SomeService` type
  5404. * from the parent
  5405. * component's injector.
  5406. * ```
  5407. * @Directive({ selector: '[my-directive]' })
  5408. * class MyDirective {
  5409. * constructor(someService: SomeService) {
  5410. * }
  5411. * }
  5412. * ```
  5413. *
  5414. * This directive would be instantiated with a dependency on `SomeService`.
  5415. *
  5416. *
  5417. * ### Injecting a directive from the current element
  5418. *
  5419. * Directives can inject other directives declared on the current element.
  5420. *
  5421. * ```
  5422. * @Directive({ selector: '[my-directive]' })
  5423. * class MyDirective {
  5424. * constructor(dependency: Dependency) {
  5425. * expect(dependency.id).toEqual(3);
  5426. * }
  5427. * }
  5428. * ```
  5429. * This directive would be instantiated with `Dependency` declared at the same element, in this case
  5430. * `dependency="3"`.
  5431. *
  5432. * ### Injecting a directive from any ancestor elements
  5433. *
  5434. * Directives can inject other directives declared on any ancestor element (in the current Shadow
  5435. * DOM), i.e. on the current element, the
  5436. * parent element, or its parents.
  5437. * ```
  5438. * @Directive({ selector: '[my-directive]' })
  5439. * class MyDirective {
  5440. * constructor(@Host() dependency: Dependency) {
  5441. * expect(dependency.id).toEqual(2);
  5442. * }
  5443. * }
  5444. * ```
  5445. *
  5446. * `@Host` checks the current element, the parent, as well as its parents recursively. If
  5447. * `dependency="2"` didn't
  5448. * exist on the direct parent, this injection would
  5449. * have returned
  5450. * `dependency="1"`.
  5451. *
  5452. *
  5453. * ### Injecting a live collection of direct child directives
  5454. *
  5455. *
  5456. * A directive can also query for other child directives. Since parent directives are instantiated
  5457. * before child directives, a directive can't simply inject the list of child directives. Instead,
  5458. * the directive injects a {@link QueryList}, which updates its contents as children are added,
  5459. * removed, or moved by a directive that uses a {@link ViewContainerRef} such as a `ngFor`, an
  5460. * `ngIf`, or an `ngSwitch`.
  5461. *
  5462. * ```
  5463. * @Directive({ selector: '[my-directive]' })
  5464. * class MyDirective {
  5465. * constructor(@Query(Dependency) dependencies:QueryList<Dependency>) {
  5466. * }
  5467. * }
  5468. * ```
  5469. *
  5470. * This directive would be instantiated with a {@link QueryList} which contains `Dependency` 4 and
  5471. * `Dependency` 6. Here, `Dependency` 5 would not be included, because it is not a direct child.
  5472. *
  5473. * ### Injecting a live collection of descendant directives
  5474. *
  5475. * By passing the descendant flag to `@Query` above, we can include the children of the child
  5476. * elements.
  5477. *
  5478. * ```
  5479. * @Directive({ selector: '[my-directive]' })
  5480. * class MyDirective {
  5481. * constructor(@Query(Dependency, {descendants: true}) dependencies:QueryList<Dependency>) {
  5482. * }
  5483. * }
  5484. * ```
  5485. *
  5486. * This directive would be instantiated with a Query which would contain `Dependency` 4, 5 and 6.
  5487. *
  5488. * ### Optional injection
  5489. *
  5490. * The normal behavior of directives is to return an error when a specified dependency cannot be
  5491. * resolved. If you
  5492. * would like to inject `null` on unresolved dependency instead, you can annotate that dependency
  5493. * with `@Optional()`.
  5494. * This explicitly permits the author of a template to treat some of the surrounding directives as
  5495. * optional.
  5496. *
  5497. * ```
  5498. * @Directive({ selector: '[my-directive]' })
  5499. * class MyDirective {
  5500. * constructor(@Optional() dependency:Dependency) {
  5501. * }
  5502. * }
  5503. * ```
  5504. *
  5505. * This directive would be instantiated with a `Dependency` directive found on the current element.
  5506. * If none can be
  5507. * found, the injector supplies `null` instead of throwing an error.
  5508. *
  5509. * ### Example
  5510. *
  5511. * Here we use a decorator directive to simply define basic tool-tip behavior.
  5512. *
  5513. * ```
  5514. * @Directive({
  5515. * selector: '[tooltip]',
  5516. * inputs: [
  5517. * 'text: tooltip'
  5518. * ],
  5519. * host: {
  5520. * '(mouseenter)': 'onMouseEnter()',
  5521. * '(mouseleave)': 'onMouseLeave()'
  5522. * }
  5523. * })
  5524. * class Tooltip{
  5525. * text:string;
  5526. * overlay:Overlay; // NOT YET IMPLEMENTED
  5527. * overlayManager:OverlayManager; // NOT YET IMPLEMENTED
  5528. *
  5529. * constructor(overlayManager:OverlayManager) {
  5530. * this.overlay = overlay;
  5531. * }
  5532. *
  5533. * onMouseEnter() {
  5534. * // exact signature to be determined
  5535. * this.overlay = this.overlayManager.open(text, ...);
  5536. * }
  5537. *
  5538. * onMouseLeave() {
  5539. * this.overlay.close();
  5540. * this.overlay = null;
  5541. * }
  5542. * }
  5543. * ```
  5544. * In our HTML template, we can then add this behavior to a `<div>` or any other element with the
  5545. * `tooltip` selector,
  5546. * like so:
  5547. *
  5548. * ```
  5549. * <div tooltip="some text here"></div>
  5550. * ```
  5551. *
  5552. * Directives can also control the instantiation, destruction, and positioning of inline template
  5553. * elements:
  5554. *
  5555. * A directive uses a {@link ViewContainerRef} to instantiate, insert, move, and destroy views at
  5556. * runtime.
  5557. * The {@link ViewContainerRef} is created as a result of `<template>` element, and represents a
  5558. * location in the current view
  5559. * where these actions are performed.
  5560. *
  5561. * Views are always created as children of the current {@link ViewMetadata}, and as siblings of the
  5562. * `<template>` element. Thus a
  5563. * directive in a child view cannot inject the directive that created it.
  5564. *
  5565. * Since directives that create views via ViewContainers are common in Angular, and using the full
  5566. * `<template>` element syntax is wordy, Angular
  5567. * also supports a shorthand notation: `<li *foo="bar">` and `<li template="foo: bar">` are
  5568. * equivalent.
  5569. *
  5570. * Thus,
  5571. *
  5572. * ```
  5573. * <ul>
  5574. * <li *foo="bar" title="text"></li>
  5575. * </ul>
  5576. * ```
  5577. *
  5578. * Expands in use to:
  5579. *
  5580. * ```
  5581. * <ul>
  5582. * <template [foo]="bar">
  5583. * <li title="text"></li>
  5584. * </template>
  5585. * </ul>
  5586. * ```
  5587. *
  5588. * Notice that although the shorthand places `*foo="bar"` within the `<li>` element, the binding for
  5589. * the directive
  5590. * controller is correctly instantiated on the `<template>` element rather than the `<li>` element.
  5591. *
  5592. * ## Lifecycle hooks
  5593. *
  5594. * When the directive class implements some {@link angular2/lifecycle_hooks} the callbacks are
  5595. * called by the change detection at defined points in time during the life of the directive.
  5596. *
  5597. * ### Example
  5598. *
  5599. * Let's suppose we want to implement the `unless` behavior, to conditionally include a template.
  5600. *
  5601. * Here is a simple directive that triggers on an `unless` selector:
  5602. *
  5603. * ```
  5604. * @Directive({
  5605. * selector: '[unless]',
  5606. * inputs: ['unless']
  5607. * })
  5608. * export class Unless {
  5609. * viewContainer: ViewContainerRef;
  5610. * templateRef: TemplateRef;
  5611. * prevCondition: boolean;
  5612. *
  5613. * constructor(viewContainer: ViewContainerRef, templateRef: TemplateRef) {
  5614. * this.viewContainer = viewContainer;
  5615. * this.templateRef = templateRef;
  5616. * this.prevCondition = null;
  5617. * }
  5618. *
  5619. * set unless(newCondition) {
  5620. * if (newCondition && (isBlank(this.prevCondition) || !this.prevCondition)) {
  5621. * this.prevCondition = true;
  5622. * this.viewContainer.clear();
  5623. * } else if (!newCondition && (isBlank(this.prevCondition) || this.prevCondition)) {
  5624. * this.prevCondition = false;
  5625. * this.viewContainer.create(this.templateRef);
  5626. * }
  5627. * }
  5628. * }
  5629. * ```
  5630. *
  5631. * We can then use this `unless` selector in a template:
  5632. * ```
  5633. * <ul>
  5634. * <li *unless="expr"></li>
  5635. * </ul>
  5636. * ```
  5637. *
  5638. * Once the directive instantiates the child view, the shorthand notation for the template expands
  5639. * and the result is:
  5640. *
  5641. * ```
  5642. * <ul>
  5643. * <template [unless]="exp">
  5644. * <li></li>
  5645. * </template>
  5646. * <li></li>
  5647. * </ul>
  5648. * ```
  5649. *
  5650. * Note also that although the `<li></li>` template still exists inside the `<template></template>`,
  5651. * the instantiated
  5652. * view occurs on the second `<li></li>` which is a sibling to the `<template>` element.
  5653. */
  5654. var DirectiveMetadata = (function (_super) {
  5655. __extends(DirectiveMetadata, _super);
  5656. function DirectiveMetadata(_a) {
  5657. var _b = _a === void 0 ? {} : _a, selector = _b.selector, inputs = _b.inputs, outputs = _b.outputs, properties = _b.properties, events = _b.events, host = _b.host, bindings = _b.bindings, providers = _b.providers, exportAs = _b.exportAs, queries = _b.queries;
  5658. _super.call(this);
  5659. this.selector = selector;
  5660. this._inputs = inputs;
  5661. this._properties = properties;
  5662. this._outputs = outputs;
  5663. this._events = events;
  5664. this.host = host;
  5665. this.exportAs = exportAs;
  5666. this.queries = queries;
  5667. this._providers = providers;
  5668. this._bindings = bindings;
  5669. }
  5670. Object.defineProperty(DirectiveMetadata.prototype, "inputs", {
  5671. /**
  5672. * Enumerates the set of data-bound input properties for a directive
  5673. *
  5674. * Angular automatically updates input properties during change detection.
  5675. *
  5676. * The `inputs` property defines a set of `directiveProperty` to `bindingProperty`
  5677. * configuration:
  5678. *
  5679. * - `directiveProperty` specifies the component property where the value is written.
  5680. * - `bindingProperty` specifies the DOM property where the value is read from.
  5681. *
  5682. * When `bindingProperty` is not provided, it is assumed to be equal to `directiveProperty`.
  5683. *
  5684. * ### Example ([live demo](http://plnkr.co/edit/ivhfXY?p=preview))
  5685. *
  5686. * The following example creates a component with two data-bound properties.
  5687. *
  5688. * ```typescript
  5689. * @Component({
  5690. * selector: 'bank-account',
  5691. * inputs: ['bankName', 'id: account-id'],
  5692. * template: `
  5693. * Bank Name: {{bankName}}
  5694. * Account Id: {{id}}
  5695. * `
  5696. * })
  5697. * class BankAccount {
  5698. * bankName: string;
  5699. * id: string;
  5700. *
  5701. * // this property is not bound, and won't be automatically updated by Angular
  5702. * normalizedBankName: string;
  5703. * }
  5704. *
  5705. * @Component({
  5706. * selector: 'app',
  5707. * template: `
  5708. * <bank-account bank-name="RBC" account-id="4747"></bank-account>
  5709. * `,
  5710. * directives: [BankAccount]
  5711. * })
  5712. * class App {}
  5713. *
  5714. * bootstrap(App);
  5715. * ```
  5716. *
  5717. */
  5718. get: function () {
  5719. return lang_1.isPresent(this._properties) && this._properties.length > 0 ? this._properties :
  5720. this._inputs;
  5721. },
  5722. enumerable: true,
  5723. configurable: true
  5724. });
  5725. Object.defineProperty(DirectiveMetadata.prototype, "properties", {
  5726. get: function () { return this.inputs; },
  5727. enumerable: true,
  5728. configurable: true
  5729. });
  5730. Object.defineProperty(DirectiveMetadata.prototype, "outputs", {
  5731. /**
  5732. * Enumerates the set of event-bound output properties.
  5733. *
  5734. * When an output property emits an event, an event handler attached to that event
  5735. * the template is invoked.
  5736. *
  5737. * The `outputs` property defines a set of `directiveProperty` to `bindingProperty`
  5738. * configuration:
  5739. *
  5740. * - `directiveProperty` specifies the component property that emits events.
  5741. * - `bindingProperty` specifies the DOM property the event handler is attached to.
  5742. *
  5743. * ### Example ([live demo](http://plnkr.co/edit/d5CNq7?p=preview))
  5744. *
  5745. * ```typescript
  5746. * @Directive({
  5747. * selector: 'interval-dir',
  5748. * outputs: ['everySecond', 'five5Secs: everyFiveSeconds']
  5749. * })
  5750. * class IntervalDir {
  5751. * everySecond = new EventEmitter();
  5752. * five5Secs = new EventEmitter();
  5753. *
  5754. * constructor() {
  5755. * setInterval(() => this.everySecond.emit("event"), 1000);
  5756. * setInterval(() => this.five5Secs.emit("event"), 5000);
  5757. * }
  5758. * }
  5759. *
  5760. * @Component({
  5761. * selector: 'app',
  5762. * template: `
  5763. * <interval-dir (every-second)="everySecond()" (every-five-seconds)="everyFiveSeconds()">
  5764. * </interval-dir>
  5765. * `,
  5766. * directives: [IntervalDir]
  5767. * })
  5768. * class App {
  5769. * everySecond() { console.log('second'); }
  5770. * everyFiveSeconds() { console.log('five seconds'); }
  5771. * }
  5772. * bootstrap(App);
  5773. * ```
  5774. *
  5775. */
  5776. get: function () {
  5777. return lang_1.isPresent(this._events) && this._events.length > 0 ? this._events : this._outputs;
  5778. },
  5779. enumerable: true,
  5780. configurable: true
  5781. });
  5782. Object.defineProperty(DirectiveMetadata.prototype, "events", {
  5783. get: function () { return this.outputs; },
  5784. enumerable: true,
  5785. configurable: true
  5786. });
  5787. Object.defineProperty(DirectiveMetadata.prototype, "providers", {
  5788. /**
  5789. * Defines the set of injectable objects that are visible to a Directive and its light DOM
  5790. * children.
  5791. *
  5792. * ## Simple Example
  5793. *
  5794. * Here is an example of a class that can be injected:
  5795. *
  5796. * ```
  5797. * class Greeter {
  5798. * greet(name:string) {
  5799. * return 'Hello ' + name + '!';
  5800. * }
  5801. * }
  5802. *
  5803. * @Directive({
  5804. * selector: 'greet',
  5805. * bindings: [
  5806. * Greeter
  5807. * ]
  5808. * })
  5809. * class HelloWorld {
  5810. * greeter:Greeter;
  5811. *
  5812. * constructor(greeter:Greeter) {
  5813. * this.greeter = greeter;
  5814. * }
  5815. * }
  5816. * ```
  5817. */
  5818. get: function () {
  5819. return lang_1.isPresent(this._bindings) && this._bindings.length > 0 ? this._bindings :
  5820. this._providers;
  5821. },
  5822. enumerable: true,
  5823. configurable: true
  5824. });
  5825. Object.defineProperty(DirectiveMetadata.prototype, "bindings", {
  5826. /** @deprecated */
  5827. get: function () { return this.providers; },
  5828. enumerable: true,
  5829. configurable: true
  5830. });
  5831. DirectiveMetadata = __decorate([
  5832. lang_1.CONST(),
  5833. __metadata('design:paramtypes', [Object])
  5834. ], DirectiveMetadata);
  5835. return DirectiveMetadata;
  5836. })(metadata_1.InjectableMetadata);
  5837. exports.DirectiveMetadata = DirectiveMetadata;
  5838. /**
  5839. * Declare reusable UI building blocks for an application.
  5840. *
  5841. * Each Angular component requires a single `@Component` annotation. The
  5842. * `@Component`
  5843. * annotation specifies when a component is instantiated, and which properties and hostListeners it
  5844. * binds to.
  5845. *
  5846. * When a component is instantiated, Angular
  5847. * - creates a shadow DOM for the component.
  5848. * - loads the selected template into the shadow DOM.
  5849. * - creates all the injectable objects configured with `providers` and `viewProviders`.
  5850. *
  5851. * All template expressions and statements are then evaluated against the component instance.
  5852. *
  5853. * For details on the `@View` annotation, see {@link ViewMetadata}.
  5854. *
  5855. * ## Lifecycle hooks
  5856. *
  5857. * When the component class implements some {@link angular2/lifecycle_hooks} the callbacks are
  5858. * called by the change detection at defined points in time during the life of the component.
  5859. *
  5860. * ### Example
  5861. *
  5862. * {@example core/ts/metadata/metadata.ts region='component'}
  5863. */
  5864. var ComponentMetadata = (function (_super) {
  5865. __extends(ComponentMetadata, _super);
  5866. function ComponentMetadata(_a) {
  5867. var _b = _a === void 0 ? {} : _a, selector = _b.selector, inputs = _b.inputs, outputs = _b.outputs, properties = _b.properties, events = _b.events, host = _b.host, exportAs = _b.exportAs, moduleId = _b.moduleId, bindings = _b.bindings, providers = _b.providers, viewBindings = _b.viewBindings, viewProviders = _b.viewProviders, _c = _b.changeDetection, changeDetection = _c === void 0 ? change_detection_1.ChangeDetectionStrategy.Default : _c, queries = _b.queries, templateUrl = _b.templateUrl, template = _b.template, styleUrls = _b.styleUrls, styles = _b.styles, directives = _b.directives, pipes = _b.pipes, encapsulation = _b.encapsulation;
  5868. _super.call(this, {
  5869. selector: selector,
  5870. inputs: inputs,
  5871. outputs: outputs,
  5872. properties: properties,
  5873. events: events,
  5874. host: host,
  5875. exportAs: exportAs,
  5876. bindings: bindings,
  5877. providers: providers,
  5878. queries: queries
  5879. });
  5880. this.changeDetection = changeDetection;
  5881. this._viewProviders = viewProviders;
  5882. this._viewBindings = viewBindings;
  5883. this.templateUrl = templateUrl;
  5884. this.template = template;
  5885. this.styleUrls = styleUrls;
  5886. this.styles = styles;
  5887. this.directives = directives;
  5888. this.pipes = pipes;
  5889. this.encapsulation = encapsulation;
  5890. this.moduleId = moduleId;
  5891. }
  5892. Object.defineProperty(ComponentMetadata.prototype, "viewProviders", {
  5893. /**
  5894. * Defines the set of injectable objects that are visible to its view DOM children.
  5895. *
  5896. * ## Simple Example
  5897. *
  5898. * Here is an example of a class that can be injected:
  5899. *
  5900. * ```
  5901. * class Greeter {
  5902. * greet(name:string) {
  5903. * return 'Hello ' + name + '!';
  5904. * }
  5905. * }
  5906. *
  5907. * @Directive({
  5908. * selector: 'needs-greeter'
  5909. * })
  5910. * class NeedsGreeter {
  5911. * greeter:Greeter;
  5912. *
  5913. * constructor(greeter:Greeter) {
  5914. * this.greeter = greeter;
  5915. * }
  5916. * }
  5917. *
  5918. * @Component({
  5919. * selector: 'greet',
  5920. * viewProviders: [
  5921. * Greeter
  5922. * ],
  5923. * template: `<needs-greeter></needs-greeter>`,
  5924. * directives: [NeedsGreeter]
  5925. * })
  5926. * class HelloWorld {
  5927. * }
  5928. *
  5929. * ```
  5930. */
  5931. get: function () {
  5932. return lang_1.isPresent(this._viewBindings) && this._viewBindings.length > 0 ? this._viewBindings :
  5933. this._viewProviders;
  5934. },
  5935. enumerable: true,
  5936. configurable: true
  5937. });
  5938. Object.defineProperty(ComponentMetadata.prototype, "viewBindings", {
  5939. get: function () { return this.viewProviders; },
  5940. enumerable: true,
  5941. configurable: true
  5942. });
  5943. ComponentMetadata = __decorate([
  5944. lang_1.CONST(),
  5945. __metadata('design:paramtypes', [Object])
  5946. ], ComponentMetadata);
  5947. return ComponentMetadata;
  5948. })(DirectiveMetadata);
  5949. exports.ComponentMetadata = ComponentMetadata;
  5950. /**
  5951. * Declare reusable pipe function.
  5952. *
  5953. * A "pure" pipe is only re-evaluated when either the input or any of the arguments change.
  5954. *
  5955. * When not specified, pipes default to being pure.
  5956. *
  5957. * ### Example
  5958. *
  5959. * {@example core/ts/metadata/metadata.ts region='pipe'}
  5960. */
  5961. var PipeMetadata = (function (_super) {
  5962. __extends(PipeMetadata, _super);
  5963. function PipeMetadata(_a) {
  5964. var name = _a.name, pure = _a.pure;
  5965. _super.call(this);
  5966. this.name = name;
  5967. this._pure = pure;
  5968. }
  5969. Object.defineProperty(PipeMetadata.prototype, "pure", {
  5970. get: function () { return lang_1.isPresent(this._pure) ? this._pure : true; },
  5971. enumerable: true,
  5972. configurable: true
  5973. });
  5974. PipeMetadata = __decorate([
  5975. lang_1.CONST(),
  5976. __metadata('design:paramtypes', [Object])
  5977. ], PipeMetadata);
  5978. return PipeMetadata;
  5979. })(metadata_1.InjectableMetadata);
  5980. exports.PipeMetadata = PipeMetadata;
  5981. /**
  5982. * Declares a data-bound input property.
  5983. *
  5984. * Angular automatically updates data-bound properties during change detection.
  5985. *
  5986. * `InputMetadata` takes an optional parameter that specifies the name
  5987. * used when instantiating a component in the template. When not provided,
  5988. * the name of the decorated property is used.
  5989. *
  5990. * ### Example
  5991. *
  5992. * The following example creates a component with two input properties.
  5993. *
  5994. * ```typescript
  5995. * @Component({
  5996. * selector: 'bank-account',
  5997. * template: `
  5998. * Bank Name: {{bankName}}
  5999. * Account Id: {{id}}
  6000. * `
  6001. * })
  6002. * class BankAccount {
  6003. * @Input() bankName: string;
  6004. * @Input('account-id') id: string;
  6005. *
  6006. * // this property is not bound, and won't be automatically updated by Angular
  6007. * normalizedBankName: string;
  6008. * }
  6009. *
  6010. * @Component({
  6011. * selector: 'app',
  6012. * template: `
  6013. * <bank-account bank-name="RBC" account-id="4747"></bank-account>
  6014. * `,
  6015. * directives: [BankAccount]
  6016. * })
  6017. * class App {}
  6018. *
  6019. * bootstrap(App);
  6020. * ```
  6021. */
  6022. var InputMetadata = (function () {
  6023. function InputMetadata(
  6024. /**
  6025. * Name used when instantiating a component in the temlate.
  6026. */
  6027. bindingPropertyName) {
  6028. this.bindingPropertyName = bindingPropertyName;
  6029. }
  6030. InputMetadata = __decorate([
  6031. lang_1.CONST(),
  6032. __metadata('design:paramtypes', [String])
  6033. ], InputMetadata);
  6034. return InputMetadata;
  6035. })();
  6036. exports.InputMetadata = InputMetadata;
  6037. /**
  6038. * Declares an event-bound output property.
  6039. *
  6040. * When an output property emits an event, an event handler attached to that event
  6041. * the template is invoked.
  6042. *
  6043. * `OutputMetadata` takes an optional parameter that specifies the name
  6044. * used when instantiating a component in the template. When not provided,
  6045. * the name of the decorated property is used.
  6046. *
  6047. * ### Example
  6048. *
  6049. * ```typescript
  6050. * @Directive({
  6051. * selector: 'interval-dir',
  6052. * })
  6053. * class IntervalDir {
  6054. * @Output() everySecond = new EventEmitter();
  6055. * @Output('everyFiveSeconds') five5Secs = new EventEmitter();
  6056. *
  6057. * constructor() {
  6058. * setInterval(() => this.everySecond.emit("event"), 1000);
  6059. * setInterval(() => this.five5Secs.emit("event"), 5000);
  6060. * }
  6061. * }
  6062. *
  6063. * @Component({
  6064. * selector: 'app',
  6065. * template: `
  6066. * <interval-dir (every-second)="everySecond()" (every-five-seconds)="everyFiveSeconds()">
  6067. * </interval-dir>
  6068. * `,
  6069. * directives: [IntervalDir]
  6070. * })
  6071. * class App {
  6072. * everySecond() { console.log('second'); }
  6073. * everyFiveSeconds() { console.log('five seconds'); }
  6074. * }
  6075. * bootstrap(App);
  6076. * ```
  6077. */
  6078. var OutputMetadata = (function () {
  6079. function OutputMetadata(bindingPropertyName) {
  6080. this.bindingPropertyName = bindingPropertyName;
  6081. }
  6082. OutputMetadata = __decorate([
  6083. lang_1.CONST(),
  6084. __metadata('design:paramtypes', [String])
  6085. ], OutputMetadata);
  6086. return OutputMetadata;
  6087. })();
  6088. exports.OutputMetadata = OutputMetadata;
  6089. /**
  6090. * Declares a host property binding.
  6091. *
  6092. * Angular automatically checks host property bindings during change detection.
  6093. * If a binding changes, it will update the host element of the directive.
  6094. *
  6095. * `HostBindingMetadata` takes an optional parameter that specifies the property
  6096. * name of the host element that will be updated. When not provided,
  6097. * the class property name is used.
  6098. *
  6099. * ### Example
  6100. *
  6101. * The following example creates a directive that sets the `valid` and `invalid` classes
  6102. * on the DOM element that has ngModel directive on it.
  6103. *
  6104. * ```typescript
  6105. * @Directive({selector: '[ngModel]'})
  6106. * class NgModelStatus {
  6107. * constructor(public control:NgModel) {}
  6108. * @HostBinding('[class.valid]') get valid { return this.control.valid; }
  6109. * @HostBinding('[class.invalid]') get invalid { return this.control.invalid; }
  6110. * }
  6111. *
  6112. * @Component({
  6113. * selector: 'app',
  6114. * template: `<input [(ngModel)]="prop">`,
  6115. * directives: [FORM_DIRECTIVES, NgModelStatus]
  6116. * })
  6117. * class App {
  6118. * prop;
  6119. * }
  6120. *
  6121. * bootstrap(App);
  6122. * ```
  6123. */
  6124. var HostBindingMetadata = (function () {
  6125. function HostBindingMetadata(hostPropertyName) {
  6126. this.hostPropertyName = hostPropertyName;
  6127. }
  6128. HostBindingMetadata = __decorate([
  6129. lang_1.CONST(),
  6130. __metadata('design:paramtypes', [String])
  6131. ], HostBindingMetadata);
  6132. return HostBindingMetadata;
  6133. })();
  6134. exports.HostBindingMetadata = HostBindingMetadata;
  6135. /**
  6136. * Declares a host listener.
  6137. *
  6138. * Angular will invoke the decorated method when the host element emits the specified event.
  6139. *
  6140. * If the decorated method returns `false`, then `preventDefault` is applied on the DOM
  6141. * event.
  6142. *
  6143. * ### Example
  6144. *
  6145. * The following example declares a directive that attaches a click listener to the button and
  6146. * counts clicks.
  6147. *
  6148. * ```typescript
  6149. * @Directive({selector: 'button[counting]'})
  6150. * class CountClicks {
  6151. * numberOfClicks = 0;
  6152. *
  6153. * @HostListener('click', ['$event.target'])
  6154. * onClick(btn) {
  6155. * console.log("button", btn, "number of clicks:", this.numberOfClicks++);
  6156. * }
  6157. * }
  6158. *
  6159. * @Component({
  6160. * selector: 'app',
  6161. * template: `<button counting>Increment</button>`,
  6162. * directives: [CountClicks]
  6163. * })
  6164. * class App {}
  6165. *
  6166. * bootstrap(App);
  6167. * ```
  6168. */
  6169. var HostListenerMetadata = (function () {
  6170. function HostListenerMetadata(eventName, args) {
  6171. this.eventName = eventName;
  6172. this.args = args;
  6173. }
  6174. HostListenerMetadata = __decorate([
  6175. lang_1.CONST(),
  6176. __metadata('design:paramtypes', [String, Array])
  6177. ], HostListenerMetadata);
  6178. return HostListenerMetadata;
  6179. })();
  6180. exports.HostListenerMetadata = HostListenerMetadata;
  6181. /***/ },
  6182. /* 24 */
  6183. /***/ function(module, exports, __webpack_require__) {
  6184. /**
  6185. * @module
  6186. * @description
  6187. * Change detection enables data binding in Angular.
  6188. */
  6189. var change_detection_1 = __webpack_require__(25);
  6190. exports.ChangeDetectionStrategy = change_detection_1.ChangeDetectionStrategy;
  6191. exports.ExpressionChangedAfterItHasBeenCheckedException = change_detection_1.ExpressionChangedAfterItHasBeenCheckedException;
  6192. exports.ChangeDetectionError = change_detection_1.ChangeDetectionError;
  6193. exports.ChangeDetectorRef = change_detection_1.ChangeDetectorRef;
  6194. exports.WrappedValue = change_detection_1.WrappedValue;
  6195. exports.SimpleChange = change_detection_1.SimpleChange;
  6196. exports.IterableDiffers = change_detection_1.IterableDiffers;
  6197. exports.KeyValueDiffers = change_detection_1.KeyValueDiffers;
  6198. /***/ },
  6199. /* 25 */
  6200. /***/ function(module, exports, __webpack_require__) {
  6201. var iterable_differs_1 = __webpack_require__(26);
  6202. var default_iterable_differ_1 = __webpack_require__(27);
  6203. var keyvalue_differs_1 = __webpack_require__(28);
  6204. var default_keyvalue_differ_1 = __webpack_require__(29);
  6205. var lang_1 = __webpack_require__(5);
  6206. var ast_1 = __webpack_require__(30);
  6207. exports.ASTWithSource = ast_1.ASTWithSource;
  6208. exports.AST = ast_1.AST;
  6209. exports.AstTransformer = ast_1.AstTransformer;
  6210. exports.PropertyRead = ast_1.PropertyRead;
  6211. exports.LiteralArray = ast_1.LiteralArray;
  6212. exports.ImplicitReceiver = ast_1.ImplicitReceiver;
  6213. var lexer_1 = __webpack_require__(31);
  6214. exports.Lexer = lexer_1.Lexer;
  6215. var parser_1 = __webpack_require__(32);
  6216. exports.Parser = parser_1.Parser;
  6217. var locals_1 = __webpack_require__(33);
  6218. exports.Locals = locals_1.Locals;
  6219. var exceptions_1 = __webpack_require__(34);
  6220. exports.DehydratedException = exceptions_1.DehydratedException;
  6221. exports.ExpressionChangedAfterItHasBeenCheckedException = exceptions_1.ExpressionChangedAfterItHasBeenCheckedException;
  6222. exports.ChangeDetectionError = exceptions_1.ChangeDetectionError;
  6223. var interfaces_1 = __webpack_require__(35);
  6224. exports.ChangeDetectorDefinition = interfaces_1.ChangeDetectorDefinition;
  6225. exports.DebugContext = interfaces_1.DebugContext;
  6226. exports.ChangeDetectorGenConfig = interfaces_1.ChangeDetectorGenConfig;
  6227. var constants_1 = __webpack_require__(36);
  6228. exports.ChangeDetectionStrategy = constants_1.ChangeDetectionStrategy;
  6229. exports.CHANGE_DETECTION_STRATEGY_VALUES = constants_1.CHANGE_DETECTION_STRATEGY_VALUES;
  6230. var proto_change_detector_1 = __webpack_require__(37);
  6231. exports.DynamicProtoChangeDetector = proto_change_detector_1.DynamicProtoChangeDetector;
  6232. var jit_proto_change_detector_1 = __webpack_require__(51);
  6233. exports.JitProtoChangeDetector = jit_proto_change_detector_1.JitProtoChangeDetector;
  6234. var binding_record_1 = __webpack_require__(40);
  6235. exports.BindingRecord = binding_record_1.BindingRecord;
  6236. exports.BindingTarget = binding_record_1.BindingTarget;
  6237. var directive_record_1 = __webpack_require__(41);
  6238. exports.DirectiveIndex = directive_record_1.DirectiveIndex;
  6239. exports.DirectiveRecord = directive_record_1.DirectiveRecord;
  6240. var dynamic_change_detector_1 = __webpack_require__(42);
  6241. exports.DynamicChangeDetector = dynamic_change_detector_1.DynamicChangeDetector;
  6242. var change_detector_ref_1 = __webpack_require__(44);
  6243. exports.ChangeDetectorRef = change_detector_ref_1.ChangeDetectorRef;
  6244. var iterable_differs_2 = __webpack_require__(26);
  6245. exports.IterableDiffers = iterable_differs_2.IterableDiffers;
  6246. var keyvalue_differs_2 = __webpack_require__(28);
  6247. exports.KeyValueDiffers = keyvalue_differs_2.KeyValueDiffers;
  6248. var change_detection_util_1 = __webpack_require__(38);
  6249. exports.WrappedValue = change_detection_util_1.WrappedValue;
  6250. exports.SimpleChange = change_detection_util_1.SimpleChange;
  6251. /**
  6252. * Structural diffing for `Object`s and `Map`s.
  6253. */
  6254. exports.keyValDiff = lang_1.CONST_EXPR([lang_1.CONST_EXPR(new default_keyvalue_differ_1.DefaultKeyValueDifferFactory())]);
  6255. /**
  6256. * Structural diffing for `Iterable` types such as `Array`s.
  6257. */
  6258. exports.iterableDiff = lang_1.CONST_EXPR([lang_1.CONST_EXPR(new default_iterable_differ_1.DefaultIterableDifferFactory())]);
  6259. exports.defaultIterableDiffers = lang_1.CONST_EXPR(new iterable_differs_1.IterableDiffers(exports.iterableDiff));
  6260. exports.defaultKeyValueDiffers = lang_1.CONST_EXPR(new keyvalue_differs_1.KeyValueDiffers(exports.keyValDiff));
  6261. /***/ },
  6262. /* 26 */
  6263. /***/ function(module, exports, __webpack_require__) {
  6264. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  6265. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  6266. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  6267. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  6268. return c > 3 && r && Object.defineProperty(target, key, r), r;
  6269. };
  6270. var __metadata = (this && this.__metadata) || function (k, v) {
  6271. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  6272. };
  6273. var lang_1 = __webpack_require__(5);
  6274. var exceptions_1 = __webpack_require__(14);
  6275. var collection_1 = __webpack_require__(12);
  6276. var di_1 = __webpack_require__(6);
  6277. /**
  6278. * A repository of different iterable diffing strategies used by NgFor, NgClass, and others.
  6279. */
  6280. var IterableDiffers = (function () {
  6281. function IterableDiffers(factories) {
  6282. this.factories = factories;
  6283. }
  6284. IterableDiffers.create = function (factories, parent) {
  6285. if (lang_1.isPresent(parent)) {
  6286. var copied = collection_1.ListWrapper.clone(parent.factories);
  6287. factories = factories.concat(copied);
  6288. return new IterableDiffers(factories);
  6289. }
  6290. else {
  6291. return new IterableDiffers(factories);
  6292. }
  6293. };
  6294. /**
  6295. * Takes an array of {@link IterableDifferFactory} and returns a provider used to extend the
  6296. * inherited {@link IterableDiffers} instance with the provided factories and return a new
  6297. * {@link IterableDiffers} instance.
  6298. *
  6299. * The following example shows how to extend an existing list of factories,
  6300. * which will only be applied to the injector for this component and its children.
  6301. * This step is all that's required to make a new {@link IterableDiffer} available.
  6302. *
  6303. * ### Example
  6304. *
  6305. * ```
  6306. * @Component({
  6307. * viewProviders: [
  6308. * IterableDiffers.extend([new ImmutableListDiffer()])
  6309. * ]
  6310. * })
  6311. * ```
  6312. */
  6313. IterableDiffers.extend = function (factories) {
  6314. return new di_1.Provider(IterableDiffers, {
  6315. useFactory: function (parent) {
  6316. if (lang_1.isBlank(parent)) {
  6317. // Typically would occur when calling IterableDiffers.extend inside of dependencies passed
  6318. // to
  6319. // bootstrap(), which would override default pipes instead of extending them.
  6320. throw new exceptions_1.BaseException('Cannot extend IterableDiffers without a parent injector');
  6321. }
  6322. return IterableDiffers.create(factories, parent);
  6323. },
  6324. // Dependency technically isn't optional, but we can provide a better error message this way.
  6325. deps: [[IterableDiffers, new di_1.SkipSelfMetadata(), new di_1.OptionalMetadata()]]
  6326. });
  6327. };
  6328. IterableDiffers.prototype.find = function (iterable) {
  6329. var factory = this.factories.find(function (f) { return f.supports(iterable); });
  6330. if (lang_1.isPresent(factory)) {
  6331. return factory;
  6332. }
  6333. else {
  6334. throw new exceptions_1.BaseException("Cannot find a differ supporting object '" + iterable + "'");
  6335. }
  6336. };
  6337. IterableDiffers = __decorate([
  6338. di_1.Injectable(),
  6339. lang_1.CONST(),
  6340. __metadata('design:paramtypes', [Array])
  6341. ], IterableDiffers);
  6342. return IterableDiffers;
  6343. })();
  6344. exports.IterableDiffers = IterableDiffers;
  6345. /***/ },
  6346. /* 27 */
  6347. /***/ function(module, exports, __webpack_require__) {
  6348. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  6349. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  6350. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  6351. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  6352. return c > 3 && r && Object.defineProperty(target, key, r), r;
  6353. };
  6354. var __metadata = (this && this.__metadata) || function (k, v) {
  6355. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  6356. };
  6357. var lang_1 = __webpack_require__(5);
  6358. var exceptions_1 = __webpack_require__(14);
  6359. var collection_1 = __webpack_require__(12);
  6360. var lang_2 = __webpack_require__(5);
  6361. var DefaultIterableDifferFactory = (function () {
  6362. function DefaultIterableDifferFactory() {
  6363. }
  6364. DefaultIterableDifferFactory.prototype.supports = function (obj) { return collection_1.isListLikeIterable(obj); };
  6365. DefaultIterableDifferFactory.prototype.create = function (cdRef) { return new DefaultIterableDiffer(); };
  6366. DefaultIterableDifferFactory = __decorate([
  6367. lang_1.CONST(),
  6368. __metadata('design:paramtypes', [])
  6369. ], DefaultIterableDifferFactory);
  6370. return DefaultIterableDifferFactory;
  6371. })();
  6372. exports.DefaultIterableDifferFactory = DefaultIterableDifferFactory;
  6373. var DefaultIterableDiffer = (function () {
  6374. function DefaultIterableDiffer() {
  6375. this._collection = null;
  6376. this._length = null;
  6377. // Keeps track of the used records at any point in time (during & across `_check()` calls)
  6378. this._linkedRecords = null;
  6379. // Keeps track of the removed records at any point in time during `_check()` calls.
  6380. this._unlinkedRecords = null;
  6381. this._previousItHead = null;
  6382. this._itHead = null;
  6383. this._itTail = null;
  6384. this._additionsHead = null;
  6385. this._additionsTail = null;
  6386. this._movesHead = null;
  6387. this._movesTail = null;
  6388. this._removalsHead = null;
  6389. this._removalsTail = null;
  6390. }
  6391. Object.defineProperty(DefaultIterableDiffer.prototype, "collection", {
  6392. get: function () { return this._collection; },
  6393. enumerable: true,
  6394. configurable: true
  6395. });
  6396. Object.defineProperty(DefaultIterableDiffer.prototype, "length", {
  6397. get: function () { return this._length; },
  6398. enumerable: true,
  6399. configurable: true
  6400. });
  6401. DefaultIterableDiffer.prototype.forEachItem = function (fn) {
  6402. var record;
  6403. for (record = this._itHead; record !== null; record = record._next) {
  6404. fn(record);
  6405. }
  6406. };
  6407. DefaultIterableDiffer.prototype.forEachPreviousItem = function (fn) {
  6408. var record;
  6409. for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
  6410. fn(record);
  6411. }
  6412. };
  6413. DefaultIterableDiffer.prototype.forEachAddedItem = function (fn) {
  6414. var record;
  6415. for (record = this._additionsHead; record !== null; record = record._nextAdded) {
  6416. fn(record);
  6417. }
  6418. };
  6419. DefaultIterableDiffer.prototype.forEachMovedItem = function (fn) {
  6420. var record;
  6421. for (record = this._movesHead; record !== null; record = record._nextMoved) {
  6422. fn(record);
  6423. }
  6424. };
  6425. DefaultIterableDiffer.prototype.forEachRemovedItem = function (fn) {
  6426. var record;
  6427. for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
  6428. fn(record);
  6429. }
  6430. };
  6431. DefaultIterableDiffer.prototype.diff = function (collection) {
  6432. if (lang_2.isBlank(collection))
  6433. collection = [];
  6434. if (!collection_1.isListLikeIterable(collection)) {
  6435. throw new exceptions_1.BaseException("Error trying to diff '" + collection + "'");
  6436. }
  6437. if (this.check(collection)) {
  6438. return this;
  6439. }
  6440. else {
  6441. return null;
  6442. }
  6443. };
  6444. DefaultIterableDiffer.prototype.onDestroy = function () { };
  6445. // todo(vicb): optim for UnmodifiableListView (frozen arrays)
  6446. DefaultIterableDiffer.prototype.check = function (collection) {
  6447. var _this = this;
  6448. this._reset();
  6449. var record = this._itHead;
  6450. var mayBeDirty = false;
  6451. var index;
  6452. var item;
  6453. if (lang_2.isArray(collection)) {
  6454. var list = collection;
  6455. this._length = collection.length;
  6456. for (index = 0; index < this._length; index++) {
  6457. item = list[index];
  6458. if (record === null || !lang_2.looseIdentical(record.item, item)) {
  6459. record = this._mismatch(record, item, index);
  6460. mayBeDirty = true;
  6461. }
  6462. else if (mayBeDirty) {
  6463. // TODO(misko): can we limit this to duplicates only?
  6464. record = this._verifyReinsertion(record, item, index);
  6465. }
  6466. record = record._next;
  6467. }
  6468. }
  6469. else {
  6470. index = 0;
  6471. collection_1.iterateListLike(collection, function (item) {
  6472. if (record === null || !lang_2.looseIdentical(record.item, item)) {
  6473. record = _this._mismatch(record, item, index);
  6474. mayBeDirty = true;
  6475. }
  6476. else if (mayBeDirty) {
  6477. // TODO(misko): can we limit this to duplicates only?
  6478. record = _this._verifyReinsertion(record, item, index);
  6479. }
  6480. record = record._next;
  6481. index++;
  6482. });
  6483. this._length = index;
  6484. }
  6485. this._truncate(record);
  6486. this._collection = collection;
  6487. return this.isDirty;
  6488. };
  6489. Object.defineProperty(DefaultIterableDiffer.prototype, "isDirty", {
  6490. // CollectionChanges is considered dirty if it has any additions, moves or removals.
  6491. get: function () {
  6492. return this._additionsHead !== null || this._movesHead !== null || this._removalsHead !== null;
  6493. },
  6494. enumerable: true,
  6495. configurable: true
  6496. });
  6497. /**
  6498. * Reset the state of the change objects to show no changes. This means set previousKey to
  6499. * currentKey, and clear all of the queues (additions, moves, removals).
  6500. * Set the previousIndexes of moved and added items to their currentIndexes
  6501. * Reset the list of additions, moves and removals
  6502. *
  6503. * @internal
  6504. */
  6505. DefaultIterableDiffer.prototype._reset = function () {
  6506. if (this.isDirty) {
  6507. var record;
  6508. var nextRecord;
  6509. for (record = this._previousItHead = this._itHead; record !== null; record = record._next) {
  6510. record._nextPrevious = record._next;
  6511. }
  6512. for (record = this._additionsHead; record !== null; record = record._nextAdded) {
  6513. record.previousIndex = record.currentIndex;
  6514. }
  6515. this._additionsHead = this._additionsTail = null;
  6516. for (record = this._movesHead; record !== null; record = nextRecord) {
  6517. record.previousIndex = record.currentIndex;
  6518. nextRecord = record._nextMoved;
  6519. }
  6520. this._movesHead = this._movesTail = null;
  6521. this._removalsHead = this._removalsTail = null;
  6522. }
  6523. };
  6524. /**
  6525. * This is the core function which handles differences between collections.
  6526. *
  6527. * - `record` is the record which we saw at this position last time. If null then it is a new
  6528. * item.
  6529. * - `item` is the current item in the collection
  6530. * - `index` is the position of the item in the collection
  6531. *
  6532. * @internal
  6533. */
  6534. DefaultIterableDiffer.prototype._mismatch = function (record, item, index) {
  6535. // The previous record after which we will append the current one.
  6536. var previousRecord;
  6537. if (record === null) {
  6538. previousRecord = this._itTail;
  6539. }
  6540. else {
  6541. previousRecord = record._prev;
  6542. // Remove the record from the collection since we know it does not match the item.
  6543. this._remove(record);
  6544. }
  6545. // Attempt to see if we have seen the item before.
  6546. record = this._linkedRecords === null ? null : this._linkedRecords.get(item, index);
  6547. if (record !== null) {
  6548. // We have seen this before, we need to move it forward in the collection.
  6549. this._moveAfter(record, previousRecord, index);
  6550. }
  6551. else {
  6552. // Never seen it, check evicted list.
  6553. record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(item);
  6554. if (record !== null) {
  6555. // It is an item which we have evicted earlier: reinsert it back into the list.
  6556. this._reinsertAfter(record, previousRecord, index);
  6557. }
  6558. else {
  6559. // It is a new item: add it.
  6560. record = this._addAfter(new CollectionChangeRecord(item), previousRecord, index);
  6561. }
  6562. }
  6563. return record;
  6564. };
  6565. /**
  6566. * This check is only needed if an array contains duplicates. (Short circuit of nothing dirty)
  6567. *
  6568. * Use case: `[a, a]` => `[b, a, a]`
  6569. *
  6570. * If we did not have this check then the insertion of `b` would:
  6571. * 1) evict first `a`
  6572. * 2) insert `b` at `0` index.
  6573. * 3) leave `a` at index `1` as is. <-- this is wrong!
  6574. * 3) reinsert `a` at index 2. <-- this is wrong!
  6575. *
  6576. * The correct behavior is:
  6577. * 1) evict first `a`
  6578. * 2) insert `b` at `0` index.
  6579. * 3) reinsert `a` at index 1.
  6580. * 3) move `a` at from `1` to `2`.
  6581. *
  6582. *
  6583. * Double check that we have not evicted a duplicate item. We need to check if the item type may
  6584. * have already been removed:
  6585. * The insertion of b will evict the first 'a'. If we don't reinsert it now it will be reinserted
  6586. * at the end. Which will show up as the two 'a's switching position. This is incorrect, since a
  6587. * better way to think of it is as insert of 'b' rather then switch 'a' with 'b' and then add 'a'
  6588. * at the end.
  6589. *
  6590. * @internal
  6591. */
  6592. DefaultIterableDiffer.prototype._verifyReinsertion = function (record, item, index) {
  6593. var reinsertRecord = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(item);
  6594. if (reinsertRecord !== null) {
  6595. record = this._reinsertAfter(reinsertRecord, record._prev, index);
  6596. }
  6597. else if (record.currentIndex != index) {
  6598. record.currentIndex = index;
  6599. this._addToMoves(record, index);
  6600. }
  6601. return record;
  6602. };
  6603. /**
  6604. * Get rid of any excess {@link CollectionChangeRecord}s from the previous collection
  6605. *
  6606. * - `record` The first excess {@link CollectionChangeRecord}.
  6607. *
  6608. * @internal
  6609. */
  6610. DefaultIterableDiffer.prototype._truncate = function (record) {
  6611. // Anything after that needs to be removed;
  6612. while (record !== null) {
  6613. var nextRecord = record._next;
  6614. this._addToRemovals(this._unlink(record));
  6615. record = nextRecord;
  6616. }
  6617. if (this._unlinkedRecords !== null) {
  6618. this._unlinkedRecords.clear();
  6619. }
  6620. if (this._additionsTail !== null) {
  6621. this._additionsTail._nextAdded = null;
  6622. }
  6623. if (this._movesTail !== null) {
  6624. this._movesTail._nextMoved = null;
  6625. }
  6626. if (this._itTail !== null) {
  6627. this._itTail._next = null;
  6628. }
  6629. if (this._removalsTail !== null) {
  6630. this._removalsTail._nextRemoved = null;
  6631. }
  6632. };
  6633. /** @internal */
  6634. DefaultIterableDiffer.prototype._reinsertAfter = function (record, prevRecord, index) {
  6635. if (this._unlinkedRecords !== null) {
  6636. this._unlinkedRecords.remove(record);
  6637. }
  6638. var prev = record._prevRemoved;
  6639. var next = record._nextRemoved;
  6640. if (prev === null) {
  6641. this._removalsHead = next;
  6642. }
  6643. else {
  6644. prev._nextRemoved = next;
  6645. }
  6646. if (next === null) {
  6647. this._removalsTail = prev;
  6648. }
  6649. else {
  6650. next._prevRemoved = prev;
  6651. }
  6652. this._insertAfter(record, prevRecord, index);
  6653. this._addToMoves(record, index);
  6654. return record;
  6655. };
  6656. /** @internal */
  6657. DefaultIterableDiffer.prototype._moveAfter = function (record, prevRecord, index) {
  6658. this._unlink(record);
  6659. this._insertAfter(record, prevRecord, index);
  6660. this._addToMoves(record, index);
  6661. return record;
  6662. };
  6663. /** @internal */
  6664. DefaultIterableDiffer.prototype._addAfter = function (record, prevRecord, index) {
  6665. this._insertAfter(record, prevRecord, index);
  6666. if (this._additionsTail === null) {
  6667. // todo(vicb)
  6668. // assert(this._additionsHead === null);
  6669. this._additionsTail = this._additionsHead = record;
  6670. }
  6671. else {
  6672. // todo(vicb)
  6673. // assert(_additionsTail._nextAdded === null);
  6674. // assert(record._nextAdded === null);
  6675. this._additionsTail = this._additionsTail._nextAdded = record;
  6676. }
  6677. return record;
  6678. };
  6679. /** @internal */
  6680. DefaultIterableDiffer.prototype._insertAfter = function (record, prevRecord, index) {
  6681. // todo(vicb)
  6682. // assert(record != prevRecord);
  6683. // assert(record._next === null);
  6684. // assert(record._prev === null);
  6685. var next = prevRecord === null ? this._itHead : prevRecord._next;
  6686. // todo(vicb)
  6687. // assert(next != record);
  6688. // assert(prevRecord != record);
  6689. record._next = next;
  6690. record._prev = prevRecord;
  6691. if (next === null) {
  6692. this._itTail = record;
  6693. }
  6694. else {
  6695. next._prev = record;
  6696. }
  6697. if (prevRecord === null) {
  6698. this._itHead = record;
  6699. }
  6700. else {
  6701. prevRecord._next = record;
  6702. }
  6703. if (this._linkedRecords === null) {
  6704. this._linkedRecords = new _DuplicateMap();
  6705. }
  6706. this._linkedRecords.put(record);
  6707. record.currentIndex = index;
  6708. return record;
  6709. };
  6710. /** @internal */
  6711. DefaultIterableDiffer.prototype._remove = function (record) {
  6712. return this._addToRemovals(this._unlink(record));
  6713. };
  6714. /** @internal */
  6715. DefaultIterableDiffer.prototype._unlink = function (record) {
  6716. if (this._linkedRecords !== null) {
  6717. this._linkedRecords.remove(record);
  6718. }
  6719. var prev = record._prev;
  6720. var next = record._next;
  6721. // todo(vicb)
  6722. // assert((record._prev = null) === null);
  6723. // assert((record._next = null) === null);
  6724. if (prev === null) {
  6725. this._itHead = next;
  6726. }
  6727. else {
  6728. prev._next = next;
  6729. }
  6730. if (next === null) {
  6731. this._itTail = prev;
  6732. }
  6733. else {
  6734. next._prev = prev;
  6735. }
  6736. return record;
  6737. };
  6738. /** @internal */
  6739. DefaultIterableDiffer.prototype._addToMoves = function (record, toIndex) {
  6740. // todo(vicb)
  6741. // assert(record._nextMoved === null);
  6742. if (record.previousIndex === toIndex) {
  6743. return record;
  6744. }
  6745. if (this._movesTail === null) {
  6746. // todo(vicb)
  6747. // assert(_movesHead === null);
  6748. this._movesTail = this._movesHead = record;
  6749. }
  6750. else {
  6751. // todo(vicb)
  6752. // assert(_movesTail._nextMoved === null);
  6753. this._movesTail = this._movesTail._nextMoved = record;
  6754. }
  6755. return record;
  6756. };
  6757. /** @internal */
  6758. DefaultIterableDiffer.prototype._addToRemovals = function (record) {
  6759. if (this._unlinkedRecords === null) {
  6760. this._unlinkedRecords = new _DuplicateMap();
  6761. }
  6762. this._unlinkedRecords.put(record);
  6763. record.currentIndex = null;
  6764. record._nextRemoved = null;
  6765. if (this._removalsTail === null) {
  6766. // todo(vicb)
  6767. // assert(_removalsHead === null);
  6768. this._removalsTail = this._removalsHead = record;
  6769. record._prevRemoved = null;
  6770. }
  6771. else {
  6772. // todo(vicb)
  6773. // assert(_removalsTail._nextRemoved === null);
  6774. // assert(record._nextRemoved === null);
  6775. record._prevRemoved = this._removalsTail;
  6776. this._removalsTail = this._removalsTail._nextRemoved = record;
  6777. }
  6778. return record;
  6779. };
  6780. DefaultIterableDiffer.prototype.toString = function () {
  6781. var record;
  6782. var list = [];
  6783. for (record = this._itHead; record !== null; record = record._next) {
  6784. list.push(record);
  6785. }
  6786. var previous = [];
  6787. for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
  6788. previous.push(record);
  6789. }
  6790. var additions = [];
  6791. for (record = this._additionsHead; record !== null; record = record._nextAdded) {
  6792. additions.push(record);
  6793. }
  6794. var moves = [];
  6795. for (record = this._movesHead; record !== null; record = record._nextMoved) {
  6796. moves.push(record);
  6797. }
  6798. var removals = [];
  6799. for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
  6800. removals.push(record);
  6801. }
  6802. return "collection: " + list.join(', ') + "\n" + "previous: " + previous.join(', ') + "\n" +
  6803. "additions: " + additions.join(', ') + "\n" + "moves: " + moves.join(', ') + "\n" +
  6804. "removals: " + removals.join(', ') + "\n";
  6805. };
  6806. return DefaultIterableDiffer;
  6807. })();
  6808. exports.DefaultIterableDiffer = DefaultIterableDiffer;
  6809. var CollectionChangeRecord = (function () {
  6810. function CollectionChangeRecord(item) {
  6811. this.item = item;
  6812. this.currentIndex = null;
  6813. this.previousIndex = null;
  6814. /** @internal */
  6815. this._nextPrevious = null;
  6816. /** @internal */
  6817. this._prev = null;
  6818. /** @internal */
  6819. this._next = null;
  6820. /** @internal */
  6821. this._prevDup = null;
  6822. /** @internal */
  6823. this._nextDup = null;
  6824. /** @internal */
  6825. this._prevRemoved = null;
  6826. /** @internal */
  6827. this._nextRemoved = null;
  6828. /** @internal */
  6829. this._nextAdded = null;
  6830. /** @internal */
  6831. this._nextMoved = null;
  6832. }
  6833. CollectionChangeRecord.prototype.toString = function () {
  6834. return this.previousIndex === this.currentIndex ?
  6835. lang_2.stringify(this.item) :
  6836. lang_2.stringify(this.item) + '[' + lang_2.stringify(this.previousIndex) + '->' +
  6837. lang_2.stringify(this.currentIndex) + ']';
  6838. };
  6839. return CollectionChangeRecord;
  6840. })();
  6841. exports.CollectionChangeRecord = CollectionChangeRecord;
  6842. // A linked list of CollectionChangeRecords with the same CollectionChangeRecord.item
  6843. var _DuplicateItemRecordList = (function () {
  6844. function _DuplicateItemRecordList() {
  6845. /** @internal */
  6846. this._head = null;
  6847. /** @internal */
  6848. this._tail = null;
  6849. }
  6850. /**
  6851. * Append the record to the list of duplicates.
  6852. *
  6853. * Note: by design all records in the list of duplicates hold the same value in record.item.
  6854. */
  6855. _DuplicateItemRecordList.prototype.add = function (record) {
  6856. if (this._head === null) {
  6857. this._head = this._tail = record;
  6858. record._nextDup = null;
  6859. record._prevDup = null;
  6860. }
  6861. else {
  6862. // todo(vicb)
  6863. // assert(record.item == _head.item ||
  6864. // record.item is num && record.item.isNaN && _head.item is num && _head.item.isNaN);
  6865. this._tail._nextDup = record;
  6866. record._prevDup = this._tail;
  6867. record._nextDup = null;
  6868. this._tail = record;
  6869. }
  6870. };
  6871. // Returns a CollectionChangeRecord having CollectionChangeRecord.item == item and
  6872. // CollectionChangeRecord.currentIndex >= afterIndex
  6873. _DuplicateItemRecordList.prototype.get = function (item, afterIndex) {
  6874. var record;
  6875. for (record = this._head; record !== null; record = record._nextDup) {
  6876. if ((afterIndex === null || afterIndex < record.currentIndex) &&
  6877. lang_2.looseIdentical(record.item, item)) {
  6878. return record;
  6879. }
  6880. }
  6881. return null;
  6882. };
  6883. /**
  6884. * Remove one {@link CollectionChangeRecord} from the list of duplicates.
  6885. *
  6886. * Returns whether the list of duplicates is empty.
  6887. */
  6888. _DuplicateItemRecordList.prototype.remove = function (record) {
  6889. // todo(vicb)
  6890. // assert(() {
  6891. // // verify that the record being removed is in the list.
  6892. // for (CollectionChangeRecord cursor = _head; cursor != null; cursor = cursor._nextDup) {
  6893. // if (identical(cursor, record)) return true;
  6894. // }
  6895. // return false;
  6896. //});
  6897. var prev = record._prevDup;
  6898. var next = record._nextDup;
  6899. if (prev === null) {
  6900. this._head = next;
  6901. }
  6902. else {
  6903. prev._nextDup = next;
  6904. }
  6905. if (next === null) {
  6906. this._tail = prev;
  6907. }
  6908. else {
  6909. next._prevDup = prev;
  6910. }
  6911. return this._head === null;
  6912. };
  6913. return _DuplicateItemRecordList;
  6914. })();
  6915. var _DuplicateMap = (function () {
  6916. function _DuplicateMap() {
  6917. this.map = new Map();
  6918. }
  6919. _DuplicateMap.prototype.put = function (record) {
  6920. // todo(vicb) handle corner cases
  6921. var key = lang_2.getMapKey(record.item);
  6922. var duplicates = this.map.get(key);
  6923. if (!lang_2.isPresent(duplicates)) {
  6924. duplicates = new _DuplicateItemRecordList();
  6925. this.map.set(key, duplicates);
  6926. }
  6927. duplicates.add(record);
  6928. };
  6929. /**
  6930. * Retrieve the `value` using key. Because the CollectionChangeRecord value maybe one which we
  6931. * have already iterated over, we use the afterIndex to pretend it is not there.
  6932. *
  6933. * Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
  6934. * have any more `a`s needs to return the last `a` not the first or second.
  6935. */
  6936. _DuplicateMap.prototype.get = function (value, afterIndex) {
  6937. if (afterIndex === void 0) { afterIndex = null; }
  6938. var key = lang_2.getMapKey(value);
  6939. var recordList = this.map.get(key);
  6940. return lang_2.isBlank(recordList) ? null : recordList.get(value, afterIndex);
  6941. };
  6942. /**
  6943. * Removes a {@link CollectionChangeRecord} from the list of duplicates.
  6944. *
  6945. * The list of duplicates also is removed from the map if it gets empty.
  6946. */
  6947. _DuplicateMap.prototype.remove = function (record) {
  6948. var key = lang_2.getMapKey(record.item);
  6949. // todo(vicb)
  6950. // assert(this.map.containsKey(key));
  6951. var recordList = this.map.get(key);
  6952. // Remove the list of duplicates when it gets empty
  6953. if (recordList.remove(record)) {
  6954. this.map.delete(key);
  6955. }
  6956. return record;
  6957. };
  6958. Object.defineProperty(_DuplicateMap.prototype, "isEmpty", {
  6959. get: function () { return this.map.size === 0; },
  6960. enumerable: true,
  6961. configurable: true
  6962. });
  6963. _DuplicateMap.prototype.clear = function () { this.map.clear(); };
  6964. _DuplicateMap.prototype.toString = function () { return '_DuplicateMap(' + lang_2.stringify(this.map) + ')'; };
  6965. return _DuplicateMap;
  6966. })();
  6967. /***/ },
  6968. /* 28 */
  6969. /***/ function(module, exports, __webpack_require__) {
  6970. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  6971. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  6972. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  6973. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  6974. return c > 3 && r && Object.defineProperty(target, key, r), r;
  6975. };
  6976. var __metadata = (this && this.__metadata) || function (k, v) {
  6977. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  6978. };
  6979. var lang_1 = __webpack_require__(5);
  6980. var exceptions_1 = __webpack_require__(14);
  6981. var collection_1 = __webpack_require__(12);
  6982. var di_1 = __webpack_require__(6);
  6983. /**
  6984. * A repository of different Map diffing strategies used by NgClass, NgStyle, and others.
  6985. */
  6986. var KeyValueDiffers = (function () {
  6987. function KeyValueDiffers(factories) {
  6988. this.factories = factories;
  6989. }
  6990. KeyValueDiffers.create = function (factories, parent) {
  6991. if (lang_1.isPresent(parent)) {
  6992. var copied = collection_1.ListWrapper.clone(parent.factories);
  6993. factories = factories.concat(copied);
  6994. return new KeyValueDiffers(factories);
  6995. }
  6996. else {
  6997. return new KeyValueDiffers(factories);
  6998. }
  6999. };
  7000. /**
  7001. * Takes an array of {@link KeyValueDifferFactory} and returns a provider used to extend the
  7002. * inherited {@link KeyValueDiffers} instance with the provided factories and return a new
  7003. * {@link KeyValueDiffers} instance.
  7004. *
  7005. * The following example shows how to extend an existing list of factories,
  7006. * which will only be applied to the injector for this component and its children.
  7007. * This step is all that's required to make a new {@link KeyValueDiffer} available.
  7008. *
  7009. * ### Example
  7010. *
  7011. * ```
  7012. * @Component({
  7013. * viewProviders: [
  7014. * KeyValueDiffers.extend([new ImmutableMapDiffer()])
  7015. * ]
  7016. * })
  7017. * ```
  7018. */
  7019. KeyValueDiffers.extend = function (factories) {
  7020. return new di_1.Provider(KeyValueDiffers, {
  7021. useFactory: function (parent) {
  7022. if (lang_1.isBlank(parent)) {
  7023. // Typically would occur when calling KeyValueDiffers.extend inside of dependencies passed
  7024. // to
  7025. // bootstrap(), which would override default pipes instead of extending them.
  7026. throw new exceptions_1.BaseException('Cannot extend KeyValueDiffers without a parent injector');
  7027. }
  7028. return KeyValueDiffers.create(factories, parent);
  7029. },
  7030. // Dependency technically isn't optional, but we can provide a better error message this way.
  7031. deps: [[KeyValueDiffers, new di_1.SkipSelfMetadata(), new di_1.OptionalMetadata()]]
  7032. });
  7033. };
  7034. KeyValueDiffers.prototype.find = function (kv) {
  7035. var factory = this.factories.find(function (f) { return f.supports(kv); });
  7036. if (lang_1.isPresent(factory)) {
  7037. return factory;
  7038. }
  7039. else {
  7040. throw new exceptions_1.BaseException("Cannot find a differ supporting object '" + kv + "'");
  7041. }
  7042. };
  7043. KeyValueDiffers = __decorate([
  7044. di_1.Injectable(),
  7045. lang_1.CONST(),
  7046. __metadata('design:paramtypes', [Array])
  7047. ], KeyValueDiffers);
  7048. return KeyValueDiffers;
  7049. })();
  7050. exports.KeyValueDiffers = KeyValueDiffers;
  7051. /***/ },
  7052. /* 29 */
  7053. /***/ function(module, exports, __webpack_require__) {
  7054. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  7055. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  7056. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  7057. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  7058. return c > 3 && r && Object.defineProperty(target, key, r), r;
  7059. };
  7060. var __metadata = (this && this.__metadata) || function (k, v) {
  7061. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  7062. };
  7063. var collection_1 = __webpack_require__(12);
  7064. var lang_1 = __webpack_require__(5);
  7065. var exceptions_1 = __webpack_require__(14);
  7066. var DefaultKeyValueDifferFactory = (function () {
  7067. function DefaultKeyValueDifferFactory() {
  7068. }
  7069. DefaultKeyValueDifferFactory.prototype.supports = function (obj) { return obj instanceof Map || lang_1.isJsObject(obj); };
  7070. DefaultKeyValueDifferFactory.prototype.create = function (cdRef) { return new DefaultKeyValueDiffer(); };
  7071. DefaultKeyValueDifferFactory = __decorate([
  7072. lang_1.CONST(),
  7073. __metadata('design:paramtypes', [])
  7074. ], DefaultKeyValueDifferFactory);
  7075. return DefaultKeyValueDifferFactory;
  7076. })();
  7077. exports.DefaultKeyValueDifferFactory = DefaultKeyValueDifferFactory;
  7078. var DefaultKeyValueDiffer = (function () {
  7079. function DefaultKeyValueDiffer() {
  7080. this._records = new Map();
  7081. this._mapHead = null;
  7082. this._previousMapHead = null;
  7083. this._changesHead = null;
  7084. this._changesTail = null;
  7085. this._additionsHead = null;
  7086. this._additionsTail = null;
  7087. this._removalsHead = null;
  7088. this._removalsTail = null;
  7089. }
  7090. Object.defineProperty(DefaultKeyValueDiffer.prototype, "isDirty", {
  7091. get: function () {
  7092. return this._additionsHead !== null || this._changesHead !== null ||
  7093. this._removalsHead !== null;
  7094. },
  7095. enumerable: true,
  7096. configurable: true
  7097. });
  7098. DefaultKeyValueDiffer.prototype.forEachItem = function (fn) {
  7099. var record;
  7100. for (record = this._mapHead; record !== null; record = record._next) {
  7101. fn(record);
  7102. }
  7103. };
  7104. DefaultKeyValueDiffer.prototype.forEachPreviousItem = function (fn) {
  7105. var record;
  7106. for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
  7107. fn(record);
  7108. }
  7109. };
  7110. DefaultKeyValueDiffer.prototype.forEachChangedItem = function (fn) {
  7111. var record;
  7112. for (record = this._changesHead; record !== null; record = record._nextChanged) {
  7113. fn(record);
  7114. }
  7115. };
  7116. DefaultKeyValueDiffer.prototype.forEachAddedItem = function (fn) {
  7117. var record;
  7118. for (record = this._additionsHead; record !== null; record = record._nextAdded) {
  7119. fn(record);
  7120. }
  7121. };
  7122. DefaultKeyValueDiffer.prototype.forEachRemovedItem = function (fn) {
  7123. var record;
  7124. for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
  7125. fn(record);
  7126. }
  7127. };
  7128. DefaultKeyValueDiffer.prototype.diff = function (map) {
  7129. if (lang_1.isBlank(map))
  7130. map = collection_1.MapWrapper.createFromPairs([]);
  7131. if (!(map instanceof Map || lang_1.isJsObject(map))) {
  7132. throw new exceptions_1.BaseException("Error trying to diff '" + map + "'");
  7133. }
  7134. if (this.check(map)) {
  7135. return this;
  7136. }
  7137. else {
  7138. return null;
  7139. }
  7140. };
  7141. DefaultKeyValueDiffer.prototype.onDestroy = function () { };
  7142. DefaultKeyValueDiffer.prototype.check = function (map) {
  7143. var _this = this;
  7144. this._reset();
  7145. var records = this._records;
  7146. var oldSeqRecord = this._mapHead;
  7147. var lastOldSeqRecord = null;
  7148. var lastNewSeqRecord = null;
  7149. var seqChanged = false;
  7150. this._forEach(map, function (value, key) {
  7151. var newSeqRecord;
  7152. if (oldSeqRecord !== null && key === oldSeqRecord.key) {
  7153. newSeqRecord = oldSeqRecord;
  7154. if (!lang_1.looseIdentical(value, oldSeqRecord.currentValue)) {
  7155. oldSeqRecord.previousValue = oldSeqRecord.currentValue;
  7156. oldSeqRecord.currentValue = value;
  7157. _this._addToChanges(oldSeqRecord);
  7158. }
  7159. }
  7160. else {
  7161. seqChanged = true;
  7162. if (oldSeqRecord !== null) {
  7163. oldSeqRecord._next = null;
  7164. _this._removeFromSeq(lastOldSeqRecord, oldSeqRecord);
  7165. _this._addToRemovals(oldSeqRecord);
  7166. }
  7167. if (records.has(key)) {
  7168. newSeqRecord = records.get(key);
  7169. }
  7170. else {
  7171. newSeqRecord = new KVChangeRecord(key);
  7172. records.set(key, newSeqRecord);
  7173. newSeqRecord.currentValue = value;
  7174. _this._addToAdditions(newSeqRecord);
  7175. }
  7176. }
  7177. if (seqChanged) {
  7178. if (_this._isInRemovals(newSeqRecord)) {
  7179. _this._removeFromRemovals(newSeqRecord);
  7180. }
  7181. if (lastNewSeqRecord == null) {
  7182. _this._mapHead = newSeqRecord;
  7183. }
  7184. else {
  7185. lastNewSeqRecord._next = newSeqRecord;
  7186. }
  7187. }
  7188. lastOldSeqRecord = oldSeqRecord;
  7189. lastNewSeqRecord = newSeqRecord;
  7190. oldSeqRecord = oldSeqRecord === null ? null : oldSeqRecord._next;
  7191. });
  7192. this._truncate(lastOldSeqRecord, oldSeqRecord);
  7193. return this.isDirty;
  7194. };
  7195. /** @internal */
  7196. DefaultKeyValueDiffer.prototype._reset = function () {
  7197. if (this.isDirty) {
  7198. var record;
  7199. // Record the state of the mapping
  7200. for (record = this._previousMapHead = this._mapHead; record !== null; record = record._next) {
  7201. record._nextPrevious = record._next;
  7202. }
  7203. for (record = this._changesHead; record !== null; record = record._nextChanged) {
  7204. record.previousValue = record.currentValue;
  7205. }
  7206. for (record = this._additionsHead; record != null; record = record._nextAdded) {
  7207. record.previousValue = record.currentValue;
  7208. }
  7209. // todo(vicb) once assert is supported
  7210. // assert(() {
  7211. // var r = _changesHead;
  7212. // while (r != null) {
  7213. // var nextRecord = r._nextChanged;
  7214. // r._nextChanged = null;
  7215. // r = nextRecord;
  7216. // }
  7217. //
  7218. // r = _additionsHead;
  7219. // while (r != null) {
  7220. // var nextRecord = r._nextAdded;
  7221. // r._nextAdded = null;
  7222. // r = nextRecord;
  7223. // }
  7224. //
  7225. // r = _removalsHead;
  7226. // while (r != null) {
  7227. // var nextRecord = r._nextRemoved;
  7228. // r._nextRemoved = null;
  7229. // r = nextRecord;
  7230. // }
  7231. //
  7232. // return true;
  7233. //});
  7234. this._changesHead = this._changesTail = null;
  7235. this._additionsHead = this._additionsTail = null;
  7236. this._removalsHead = this._removalsTail = null;
  7237. }
  7238. };
  7239. /** @internal */
  7240. DefaultKeyValueDiffer.prototype._truncate = function (lastRecord, record) {
  7241. while (record !== null) {
  7242. if (lastRecord === null) {
  7243. this._mapHead = null;
  7244. }
  7245. else {
  7246. lastRecord._next = null;
  7247. }
  7248. var nextRecord = record._next;
  7249. // todo(vicb) assert
  7250. // assert((() {
  7251. // record._next = null;
  7252. // return true;
  7253. //}));
  7254. this._addToRemovals(record);
  7255. lastRecord = record;
  7256. record = nextRecord;
  7257. }
  7258. for (var rec = this._removalsHead; rec !== null; rec = rec._nextRemoved) {
  7259. rec.previousValue = rec.currentValue;
  7260. rec.currentValue = null;
  7261. this._records.delete(rec.key);
  7262. }
  7263. };
  7264. /** @internal */
  7265. DefaultKeyValueDiffer.prototype._isInRemovals = function (record) {
  7266. return record === this._removalsHead || record._nextRemoved !== null ||
  7267. record._prevRemoved !== null;
  7268. };
  7269. /** @internal */
  7270. DefaultKeyValueDiffer.prototype._addToRemovals = function (record) {
  7271. // todo(vicb) assert
  7272. // assert(record._next == null);
  7273. // assert(record._nextAdded == null);
  7274. // assert(record._nextChanged == null);
  7275. // assert(record._nextRemoved == null);
  7276. // assert(record._prevRemoved == null);
  7277. if (this._removalsHead === null) {
  7278. this._removalsHead = this._removalsTail = record;
  7279. }
  7280. else {
  7281. this._removalsTail._nextRemoved = record;
  7282. record._prevRemoved = this._removalsTail;
  7283. this._removalsTail = record;
  7284. }
  7285. };
  7286. /** @internal */
  7287. DefaultKeyValueDiffer.prototype._removeFromSeq = function (prev, record) {
  7288. var next = record._next;
  7289. if (prev === null) {
  7290. this._mapHead = next;
  7291. }
  7292. else {
  7293. prev._next = next;
  7294. }
  7295. // todo(vicb) assert
  7296. // assert((() {
  7297. // record._next = null;
  7298. // return true;
  7299. //})());
  7300. };
  7301. /** @internal */
  7302. DefaultKeyValueDiffer.prototype._removeFromRemovals = function (record) {
  7303. // todo(vicb) assert
  7304. // assert(record._next == null);
  7305. // assert(record._nextAdded == null);
  7306. // assert(record._nextChanged == null);
  7307. var prev = record._prevRemoved;
  7308. var next = record._nextRemoved;
  7309. if (prev === null) {
  7310. this._removalsHead = next;
  7311. }
  7312. else {
  7313. prev._nextRemoved = next;
  7314. }
  7315. if (next === null) {
  7316. this._removalsTail = prev;
  7317. }
  7318. else {
  7319. next._prevRemoved = prev;
  7320. }
  7321. record._prevRemoved = record._nextRemoved = null;
  7322. };
  7323. /** @internal */
  7324. DefaultKeyValueDiffer.prototype._addToAdditions = function (record) {
  7325. // todo(vicb): assert
  7326. // assert(record._next == null);
  7327. // assert(record._nextAdded == null);
  7328. // assert(record._nextChanged == null);
  7329. // assert(record._nextRemoved == null);
  7330. // assert(record._prevRemoved == null);
  7331. if (this._additionsHead === null) {
  7332. this._additionsHead = this._additionsTail = record;
  7333. }
  7334. else {
  7335. this._additionsTail._nextAdded = record;
  7336. this._additionsTail = record;
  7337. }
  7338. };
  7339. /** @internal */
  7340. DefaultKeyValueDiffer.prototype._addToChanges = function (record) {
  7341. // todo(vicb) assert
  7342. // assert(record._nextAdded == null);
  7343. // assert(record._nextChanged == null);
  7344. // assert(record._nextRemoved == null);
  7345. // assert(record._prevRemoved == null);
  7346. if (this._changesHead === null) {
  7347. this._changesHead = this._changesTail = record;
  7348. }
  7349. else {
  7350. this._changesTail._nextChanged = record;
  7351. this._changesTail = record;
  7352. }
  7353. };
  7354. DefaultKeyValueDiffer.prototype.toString = function () {
  7355. var items = [];
  7356. var previous = [];
  7357. var changes = [];
  7358. var additions = [];
  7359. var removals = [];
  7360. var record;
  7361. for (record = this._mapHead; record !== null; record = record._next) {
  7362. items.push(lang_1.stringify(record));
  7363. }
  7364. for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
  7365. previous.push(lang_1.stringify(record));
  7366. }
  7367. for (record = this._changesHead; record !== null; record = record._nextChanged) {
  7368. changes.push(lang_1.stringify(record));
  7369. }
  7370. for (record = this._additionsHead; record !== null; record = record._nextAdded) {
  7371. additions.push(lang_1.stringify(record));
  7372. }
  7373. for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
  7374. removals.push(lang_1.stringify(record));
  7375. }
  7376. return "map: " + items.join(', ') + "\n" + "previous: " + previous.join(', ') + "\n" +
  7377. "additions: " + additions.join(', ') + "\n" + "changes: " + changes.join(', ') + "\n" +
  7378. "removals: " + removals.join(', ') + "\n";
  7379. };
  7380. /** @internal */
  7381. DefaultKeyValueDiffer.prototype._forEach = function (obj, fn) {
  7382. if (obj instanceof Map) {
  7383. obj.forEach(fn);
  7384. }
  7385. else {
  7386. collection_1.StringMapWrapper.forEach(obj, fn);
  7387. }
  7388. };
  7389. return DefaultKeyValueDiffer;
  7390. })();
  7391. exports.DefaultKeyValueDiffer = DefaultKeyValueDiffer;
  7392. var KVChangeRecord = (function () {
  7393. function KVChangeRecord(key) {
  7394. this.key = key;
  7395. this.previousValue = null;
  7396. this.currentValue = null;
  7397. /** @internal */
  7398. this._nextPrevious = null;
  7399. /** @internal */
  7400. this._next = null;
  7401. /** @internal */
  7402. this._nextAdded = null;
  7403. /** @internal */
  7404. this._nextRemoved = null;
  7405. /** @internal */
  7406. this._prevRemoved = null;
  7407. /** @internal */
  7408. this._nextChanged = null;
  7409. }
  7410. KVChangeRecord.prototype.toString = function () {
  7411. return lang_1.looseIdentical(this.previousValue, this.currentValue) ?
  7412. lang_1.stringify(this.key) :
  7413. (lang_1.stringify(this.key) + '[' + lang_1.stringify(this.previousValue) + '->' +
  7414. lang_1.stringify(this.currentValue) + ']');
  7415. };
  7416. return KVChangeRecord;
  7417. })();
  7418. exports.KVChangeRecord = KVChangeRecord;
  7419. /***/ },
  7420. /* 30 */
  7421. /***/ function(module, exports, __webpack_require__) {
  7422. var __extends = (this && this.__extends) || function (d, b) {
  7423. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  7424. function __() { this.constructor = d; }
  7425. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7426. };
  7427. var collection_1 = __webpack_require__(12);
  7428. var AST = (function () {
  7429. function AST() {
  7430. }
  7431. AST.prototype.visit = function (visitor) { return null; };
  7432. AST.prototype.toString = function () { return "AST"; };
  7433. return AST;
  7434. })();
  7435. exports.AST = AST;
  7436. /**
  7437. * Represents a quoted expression of the form:
  7438. *
  7439. * quote = prefix `:` uninterpretedExpression
  7440. * prefix = identifier
  7441. * uninterpretedExpression = arbitrary string
  7442. *
  7443. * A quoted expression is meant to be pre-processed by an AST transformer that
  7444. * converts it into another AST that no longer contains quoted expressions.
  7445. * It is meant to allow third-party developers to extend Angular template
  7446. * expression language. The `uninterpretedExpression` part of the quote is
  7447. * therefore not interpreted by the Angular's own expression parser.
  7448. */
  7449. var Quote = (function (_super) {
  7450. __extends(Quote, _super);
  7451. function Quote(prefix, uninterpretedExpression, location) {
  7452. _super.call(this);
  7453. this.prefix = prefix;
  7454. this.uninterpretedExpression = uninterpretedExpression;
  7455. this.location = location;
  7456. }
  7457. Quote.prototype.visit = function (visitor) { return visitor.visitQuote(this); };
  7458. Quote.prototype.toString = function () { return "Quote"; };
  7459. return Quote;
  7460. })(AST);
  7461. exports.Quote = Quote;
  7462. var EmptyExpr = (function (_super) {
  7463. __extends(EmptyExpr, _super);
  7464. function EmptyExpr() {
  7465. _super.apply(this, arguments);
  7466. }
  7467. EmptyExpr.prototype.visit = function (visitor) {
  7468. // do nothing
  7469. };
  7470. return EmptyExpr;
  7471. })(AST);
  7472. exports.EmptyExpr = EmptyExpr;
  7473. var ImplicitReceiver = (function (_super) {
  7474. __extends(ImplicitReceiver, _super);
  7475. function ImplicitReceiver() {
  7476. _super.apply(this, arguments);
  7477. }
  7478. ImplicitReceiver.prototype.visit = function (visitor) { return visitor.visitImplicitReceiver(this); };
  7479. return ImplicitReceiver;
  7480. })(AST);
  7481. exports.ImplicitReceiver = ImplicitReceiver;
  7482. /**
  7483. * Multiple expressions separated by a semicolon.
  7484. */
  7485. var Chain = (function (_super) {
  7486. __extends(Chain, _super);
  7487. function Chain(expressions) {
  7488. _super.call(this);
  7489. this.expressions = expressions;
  7490. }
  7491. Chain.prototype.visit = function (visitor) { return visitor.visitChain(this); };
  7492. return Chain;
  7493. })(AST);
  7494. exports.Chain = Chain;
  7495. var Conditional = (function (_super) {
  7496. __extends(Conditional, _super);
  7497. function Conditional(condition, trueExp, falseExp) {
  7498. _super.call(this);
  7499. this.condition = condition;
  7500. this.trueExp = trueExp;
  7501. this.falseExp = falseExp;
  7502. }
  7503. Conditional.prototype.visit = function (visitor) { return visitor.visitConditional(this); };
  7504. return Conditional;
  7505. })(AST);
  7506. exports.Conditional = Conditional;
  7507. var PropertyRead = (function (_super) {
  7508. __extends(PropertyRead, _super);
  7509. function PropertyRead(receiver, name, getter) {
  7510. _super.call(this);
  7511. this.receiver = receiver;
  7512. this.name = name;
  7513. this.getter = getter;
  7514. }
  7515. PropertyRead.prototype.visit = function (visitor) { return visitor.visitPropertyRead(this); };
  7516. return PropertyRead;
  7517. })(AST);
  7518. exports.PropertyRead = PropertyRead;
  7519. var PropertyWrite = (function (_super) {
  7520. __extends(PropertyWrite, _super);
  7521. function PropertyWrite(receiver, name, setter, value) {
  7522. _super.call(this);
  7523. this.receiver = receiver;
  7524. this.name = name;
  7525. this.setter = setter;
  7526. this.value = value;
  7527. }
  7528. PropertyWrite.prototype.visit = function (visitor) { return visitor.visitPropertyWrite(this); };
  7529. return PropertyWrite;
  7530. })(AST);
  7531. exports.PropertyWrite = PropertyWrite;
  7532. var SafePropertyRead = (function (_super) {
  7533. __extends(SafePropertyRead, _super);
  7534. function SafePropertyRead(receiver, name, getter) {
  7535. _super.call(this);
  7536. this.receiver = receiver;
  7537. this.name = name;
  7538. this.getter = getter;
  7539. }
  7540. SafePropertyRead.prototype.visit = function (visitor) { return visitor.visitSafePropertyRead(this); };
  7541. return SafePropertyRead;
  7542. })(AST);
  7543. exports.SafePropertyRead = SafePropertyRead;
  7544. var KeyedRead = (function (_super) {
  7545. __extends(KeyedRead, _super);
  7546. function KeyedRead(obj, key) {
  7547. _super.call(this);
  7548. this.obj = obj;
  7549. this.key = key;
  7550. }
  7551. KeyedRead.prototype.visit = function (visitor) { return visitor.visitKeyedRead(this); };
  7552. return KeyedRead;
  7553. })(AST);
  7554. exports.KeyedRead = KeyedRead;
  7555. var KeyedWrite = (function (_super) {
  7556. __extends(KeyedWrite, _super);
  7557. function KeyedWrite(obj, key, value) {
  7558. _super.call(this);
  7559. this.obj = obj;
  7560. this.key = key;
  7561. this.value = value;
  7562. }
  7563. KeyedWrite.prototype.visit = function (visitor) { return visitor.visitKeyedWrite(this); };
  7564. return KeyedWrite;
  7565. })(AST);
  7566. exports.KeyedWrite = KeyedWrite;
  7567. var BindingPipe = (function (_super) {
  7568. __extends(BindingPipe, _super);
  7569. function BindingPipe(exp, name, args) {
  7570. _super.call(this);
  7571. this.exp = exp;
  7572. this.name = name;
  7573. this.args = args;
  7574. }
  7575. BindingPipe.prototype.visit = function (visitor) { return visitor.visitPipe(this); };
  7576. return BindingPipe;
  7577. })(AST);
  7578. exports.BindingPipe = BindingPipe;
  7579. var LiteralPrimitive = (function (_super) {
  7580. __extends(LiteralPrimitive, _super);
  7581. function LiteralPrimitive(value) {
  7582. _super.call(this);
  7583. this.value = value;
  7584. }
  7585. LiteralPrimitive.prototype.visit = function (visitor) { return visitor.visitLiteralPrimitive(this); };
  7586. return LiteralPrimitive;
  7587. })(AST);
  7588. exports.LiteralPrimitive = LiteralPrimitive;
  7589. var LiteralArray = (function (_super) {
  7590. __extends(LiteralArray, _super);
  7591. function LiteralArray(expressions) {
  7592. _super.call(this);
  7593. this.expressions = expressions;
  7594. }
  7595. LiteralArray.prototype.visit = function (visitor) { return visitor.visitLiteralArray(this); };
  7596. return LiteralArray;
  7597. })(AST);
  7598. exports.LiteralArray = LiteralArray;
  7599. var LiteralMap = (function (_super) {
  7600. __extends(LiteralMap, _super);
  7601. function LiteralMap(keys, values) {
  7602. _super.call(this);
  7603. this.keys = keys;
  7604. this.values = values;
  7605. }
  7606. LiteralMap.prototype.visit = function (visitor) { return visitor.visitLiteralMap(this); };
  7607. return LiteralMap;
  7608. })(AST);
  7609. exports.LiteralMap = LiteralMap;
  7610. var Interpolation = (function (_super) {
  7611. __extends(Interpolation, _super);
  7612. function Interpolation(strings, expressions) {
  7613. _super.call(this);
  7614. this.strings = strings;
  7615. this.expressions = expressions;
  7616. }
  7617. Interpolation.prototype.visit = function (visitor) { return visitor.visitInterpolation(this); };
  7618. return Interpolation;
  7619. })(AST);
  7620. exports.Interpolation = Interpolation;
  7621. var Binary = (function (_super) {
  7622. __extends(Binary, _super);
  7623. function Binary(operation, left, right) {
  7624. _super.call(this);
  7625. this.operation = operation;
  7626. this.left = left;
  7627. this.right = right;
  7628. }
  7629. Binary.prototype.visit = function (visitor) { return visitor.visitBinary(this); };
  7630. return Binary;
  7631. })(AST);
  7632. exports.Binary = Binary;
  7633. var PrefixNot = (function (_super) {
  7634. __extends(PrefixNot, _super);
  7635. function PrefixNot(expression) {
  7636. _super.call(this);
  7637. this.expression = expression;
  7638. }
  7639. PrefixNot.prototype.visit = function (visitor) { return visitor.visitPrefixNot(this); };
  7640. return PrefixNot;
  7641. })(AST);
  7642. exports.PrefixNot = PrefixNot;
  7643. var MethodCall = (function (_super) {
  7644. __extends(MethodCall, _super);
  7645. function MethodCall(receiver, name, fn, args) {
  7646. _super.call(this);
  7647. this.receiver = receiver;
  7648. this.name = name;
  7649. this.fn = fn;
  7650. this.args = args;
  7651. }
  7652. MethodCall.prototype.visit = function (visitor) { return visitor.visitMethodCall(this); };
  7653. return MethodCall;
  7654. })(AST);
  7655. exports.MethodCall = MethodCall;
  7656. var SafeMethodCall = (function (_super) {
  7657. __extends(SafeMethodCall, _super);
  7658. function SafeMethodCall(receiver, name, fn, args) {
  7659. _super.call(this);
  7660. this.receiver = receiver;
  7661. this.name = name;
  7662. this.fn = fn;
  7663. this.args = args;
  7664. }
  7665. SafeMethodCall.prototype.visit = function (visitor) { return visitor.visitSafeMethodCall(this); };
  7666. return SafeMethodCall;
  7667. })(AST);
  7668. exports.SafeMethodCall = SafeMethodCall;
  7669. var FunctionCall = (function (_super) {
  7670. __extends(FunctionCall, _super);
  7671. function FunctionCall(target, args) {
  7672. _super.call(this);
  7673. this.target = target;
  7674. this.args = args;
  7675. }
  7676. FunctionCall.prototype.visit = function (visitor) { return visitor.visitFunctionCall(this); };
  7677. return FunctionCall;
  7678. })(AST);
  7679. exports.FunctionCall = FunctionCall;
  7680. var ASTWithSource = (function (_super) {
  7681. __extends(ASTWithSource, _super);
  7682. function ASTWithSource(ast, source, location) {
  7683. _super.call(this);
  7684. this.ast = ast;
  7685. this.source = source;
  7686. this.location = location;
  7687. }
  7688. ASTWithSource.prototype.visit = function (visitor) { return this.ast.visit(visitor); };
  7689. ASTWithSource.prototype.toString = function () { return this.source + " in " + this.location; };
  7690. return ASTWithSource;
  7691. })(AST);
  7692. exports.ASTWithSource = ASTWithSource;
  7693. var TemplateBinding = (function () {
  7694. function TemplateBinding(key, keyIsVar, name, expression) {
  7695. this.key = key;
  7696. this.keyIsVar = keyIsVar;
  7697. this.name = name;
  7698. this.expression = expression;
  7699. }
  7700. return TemplateBinding;
  7701. })();
  7702. exports.TemplateBinding = TemplateBinding;
  7703. var RecursiveAstVisitor = (function () {
  7704. function RecursiveAstVisitor() {
  7705. }
  7706. RecursiveAstVisitor.prototype.visitBinary = function (ast) {
  7707. ast.left.visit(this);
  7708. ast.right.visit(this);
  7709. return null;
  7710. };
  7711. RecursiveAstVisitor.prototype.visitChain = function (ast) { return this.visitAll(ast.expressions); };
  7712. RecursiveAstVisitor.prototype.visitConditional = function (ast) {
  7713. ast.condition.visit(this);
  7714. ast.trueExp.visit(this);
  7715. ast.falseExp.visit(this);
  7716. return null;
  7717. };
  7718. RecursiveAstVisitor.prototype.visitPipe = function (ast) {
  7719. ast.exp.visit(this);
  7720. this.visitAll(ast.args);
  7721. return null;
  7722. };
  7723. RecursiveAstVisitor.prototype.visitFunctionCall = function (ast) {
  7724. ast.target.visit(this);
  7725. this.visitAll(ast.args);
  7726. return null;
  7727. };
  7728. RecursiveAstVisitor.prototype.visitImplicitReceiver = function (ast) { return null; };
  7729. RecursiveAstVisitor.prototype.visitInterpolation = function (ast) { return this.visitAll(ast.expressions); };
  7730. RecursiveAstVisitor.prototype.visitKeyedRead = function (ast) {
  7731. ast.obj.visit(this);
  7732. ast.key.visit(this);
  7733. return null;
  7734. };
  7735. RecursiveAstVisitor.prototype.visitKeyedWrite = function (ast) {
  7736. ast.obj.visit(this);
  7737. ast.key.visit(this);
  7738. ast.value.visit(this);
  7739. return null;
  7740. };
  7741. RecursiveAstVisitor.prototype.visitLiteralArray = function (ast) { return this.visitAll(ast.expressions); };
  7742. RecursiveAstVisitor.prototype.visitLiteralMap = function (ast) { return this.visitAll(ast.values); };
  7743. RecursiveAstVisitor.prototype.visitLiteralPrimitive = function (ast) { return null; };
  7744. RecursiveAstVisitor.prototype.visitMethodCall = function (ast) {
  7745. ast.receiver.visit(this);
  7746. return this.visitAll(ast.args);
  7747. };
  7748. RecursiveAstVisitor.prototype.visitPrefixNot = function (ast) {
  7749. ast.expression.visit(this);
  7750. return null;
  7751. };
  7752. RecursiveAstVisitor.prototype.visitPropertyRead = function (ast) {
  7753. ast.receiver.visit(this);
  7754. return null;
  7755. };
  7756. RecursiveAstVisitor.prototype.visitPropertyWrite = function (ast) {
  7757. ast.receiver.visit(this);
  7758. ast.value.visit(this);
  7759. return null;
  7760. };
  7761. RecursiveAstVisitor.prototype.visitSafePropertyRead = function (ast) {
  7762. ast.receiver.visit(this);
  7763. return null;
  7764. };
  7765. RecursiveAstVisitor.prototype.visitSafeMethodCall = function (ast) {
  7766. ast.receiver.visit(this);
  7767. return this.visitAll(ast.args);
  7768. };
  7769. RecursiveAstVisitor.prototype.visitAll = function (asts) {
  7770. var _this = this;
  7771. asts.forEach(function (ast) { return ast.visit(_this); });
  7772. return null;
  7773. };
  7774. RecursiveAstVisitor.prototype.visitQuote = function (ast) { return null; };
  7775. return RecursiveAstVisitor;
  7776. })();
  7777. exports.RecursiveAstVisitor = RecursiveAstVisitor;
  7778. var AstTransformer = (function () {
  7779. function AstTransformer() {
  7780. }
  7781. AstTransformer.prototype.visitImplicitReceiver = function (ast) { return ast; };
  7782. AstTransformer.prototype.visitInterpolation = function (ast) {
  7783. return new Interpolation(ast.strings, this.visitAll(ast.expressions));
  7784. };
  7785. AstTransformer.prototype.visitLiteralPrimitive = function (ast) { return new LiteralPrimitive(ast.value); };
  7786. AstTransformer.prototype.visitPropertyRead = function (ast) {
  7787. return new PropertyRead(ast.receiver.visit(this), ast.name, ast.getter);
  7788. };
  7789. AstTransformer.prototype.visitPropertyWrite = function (ast) {
  7790. return new PropertyWrite(ast.receiver.visit(this), ast.name, ast.setter, ast.value);
  7791. };
  7792. AstTransformer.prototype.visitSafePropertyRead = function (ast) {
  7793. return new SafePropertyRead(ast.receiver.visit(this), ast.name, ast.getter);
  7794. };
  7795. AstTransformer.prototype.visitMethodCall = function (ast) {
  7796. return new MethodCall(ast.receiver.visit(this), ast.name, ast.fn, this.visitAll(ast.args));
  7797. };
  7798. AstTransformer.prototype.visitSafeMethodCall = function (ast) {
  7799. return new SafeMethodCall(ast.receiver.visit(this), ast.name, ast.fn, this.visitAll(ast.args));
  7800. };
  7801. AstTransformer.prototype.visitFunctionCall = function (ast) {
  7802. return new FunctionCall(ast.target.visit(this), this.visitAll(ast.args));
  7803. };
  7804. AstTransformer.prototype.visitLiteralArray = function (ast) {
  7805. return new LiteralArray(this.visitAll(ast.expressions));
  7806. };
  7807. AstTransformer.prototype.visitLiteralMap = function (ast) {
  7808. return new LiteralMap(ast.keys, this.visitAll(ast.values));
  7809. };
  7810. AstTransformer.prototype.visitBinary = function (ast) {
  7811. return new Binary(ast.operation, ast.left.visit(this), ast.right.visit(this));
  7812. };
  7813. AstTransformer.prototype.visitPrefixNot = function (ast) { return new PrefixNot(ast.expression.visit(this)); };
  7814. AstTransformer.prototype.visitConditional = function (ast) {
  7815. return new Conditional(ast.condition.visit(this), ast.trueExp.visit(this), ast.falseExp.visit(this));
  7816. };
  7817. AstTransformer.prototype.visitPipe = function (ast) {
  7818. return new BindingPipe(ast.exp.visit(this), ast.name, this.visitAll(ast.args));
  7819. };
  7820. AstTransformer.prototype.visitKeyedRead = function (ast) {
  7821. return new KeyedRead(ast.obj.visit(this), ast.key.visit(this));
  7822. };
  7823. AstTransformer.prototype.visitKeyedWrite = function (ast) {
  7824. return new KeyedWrite(ast.obj.visit(this), ast.key.visit(this), ast.value.visit(this));
  7825. };
  7826. AstTransformer.prototype.visitAll = function (asts) {
  7827. var res = collection_1.ListWrapper.createFixedSize(asts.length);
  7828. for (var i = 0; i < asts.length; ++i) {
  7829. res[i] = asts[i].visit(this);
  7830. }
  7831. return res;
  7832. };
  7833. AstTransformer.prototype.visitChain = function (ast) { return new Chain(this.visitAll(ast.expressions)); };
  7834. AstTransformer.prototype.visitQuote = function (ast) {
  7835. return new Quote(ast.prefix, ast.uninterpretedExpression, ast.location);
  7836. };
  7837. return AstTransformer;
  7838. })();
  7839. exports.AstTransformer = AstTransformer;
  7840. /***/ },
  7841. /* 31 */
  7842. /***/ function(module, exports, __webpack_require__) {
  7843. var __extends = (this && this.__extends) || function (d, b) {
  7844. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  7845. function __() { this.constructor = d; }
  7846. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7847. };
  7848. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  7849. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  7850. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  7851. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  7852. return c > 3 && r && Object.defineProperty(target, key, r), r;
  7853. };
  7854. var __metadata = (this && this.__metadata) || function (k, v) {
  7855. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  7856. };
  7857. var decorators_1 = __webpack_require__(8);
  7858. var collection_1 = __webpack_require__(12);
  7859. var lang_1 = __webpack_require__(5);
  7860. var exceptions_1 = __webpack_require__(14);
  7861. (function (TokenType) {
  7862. TokenType[TokenType["Character"] = 0] = "Character";
  7863. TokenType[TokenType["Identifier"] = 1] = "Identifier";
  7864. TokenType[TokenType["Keyword"] = 2] = "Keyword";
  7865. TokenType[TokenType["String"] = 3] = "String";
  7866. TokenType[TokenType["Operator"] = 4] = "Operator";
  7867. TokenType[TokenType["Number"] = 5] = "Number";
  7868. })(exports.TokenType || (exports.TokenType = {}));
  7869. var TokenType = exports.TokenType;
  7870. var Lexer = (function () {
  7871. function Lexer() {
  7872. }
  7873. Lexer.prototype.tokenize = function (text) {
  7874. var scanner = new _Scanner(text);
  7875. var tokens = [];
  7876. var token = scanner.scanToken();
  7877. while (token != null) {
  7878. tokens.push(token);
  7879. token = scanner.scanToken();
  7880. }
  7881. return tokens;
  7882. };
  7883. Lexer = __decorate([
  7884. decorators_1.Injectable(),
  7885. __metadata('design:paramtypes', [])
  7886. ], Lexer);
  7887. return Lexer;
  7888. })();
  7889. exports.Lexer = Lexer;
  7890. var Token = (function () {
  7891. function Token(index, type, numValue, strValue) {
  7892. this.index = index;
  7893. this.type = type;
  7894. this.numValue = numValue;
  7895. this.strValue = strValue;
  7896. }
  7897. Token.prototype.isCharacter = function (code) {
  7898. return (this.type == TokenType.Character && this.numValue == code);
  7899. };
  7900. Token.prototype.isNumber = function () { return (this.type == TokenType.Number); };
  7901. Token.prototype.isString = function () { return (this.type == TokenType.String); };
  7902. Token.prototype.isOperator = function (operater) {
  7903. return (this.type == TokenType.Operator && this.strValue == operater);
  7904. };
  7905. Token.prototype.isIdentifier = function () { return (this.type == TokenType.Identifier); };
  7906. Token.prototype.isKeyword = function () { return (this.type == TokenType.Keyword); };
  7907. Token.prototype.isKeywordVar = function () { return (this.type == TokenType.Keyword && this.strValue == "var"); };
  7908. Token.prototype.isKeywordNull = function () { return (this.type == TokenType.Keyword && this.strValue == "null"); };
  7909. Token.prototype.isKeywordUndefined = function () {
  7910. return (this.type == TokenType.Keyword && this.strValue == "undefined");
  7911. };
  7912. Token.prototype.isKeywordTrue = function () { return (this.type == TokenType.Keyword && this.strValue == "true"); };
  7913. Token.prototype.isKeywordFalse = function () { return (this.type == TokenType.Keyword && this.strValue == "false"); };
  7914. Token.prototype.toNumber = function () {
  7915. // -1 instead of NULL ok?
  7916. return (this.type == TokenType.Number) ? this.numValue : -1;
  7917. };
  7918. Token.prototype.toString = function () {
  7919. switch (this.type) {
  7920. case TokenType.Character:
  7921. case TokenType.Identifier:
  7922. case TokenType.Keyword:
  7923. case TokenType.Operator:
  7924. case TokenType.String:
  7925. return this.strValue;
  7926. case TokenType.Number:
  7927. return this.numValue.toString();
  7928. default:
  7929. return null;
  7930. }
  7931. };
  7932. return Token;
  7933. })();
  7934. exports.Token = Token;
  7935. function newCharacterToken(index, code) {
  7936. return new Token(index, TokenType.Character, code, lang_1.StringWrapper.fromCharCode(code));
  7937. }
  7938. function newIdentifierToken(index, text) {
  7939. return new Token(index, TokenType.Identifier, 0, text);
  7940. }
  7941. function newKeywordToken(index, text) {
  7942. return new Token(index, TokenType.Keyword, 0, text);
  7943. }
  7944. function newOperatorToken(index, text) {
  7945. return new Token(index, TokenType.Operator, 0, text);
  7946. }
  7947. function newStringToken(index, text) {
  7948. return new Token(index, TokenType.String, 0, text);
  7949. }
  7950. function newNumberToken(index, n) {
  7951. return new Token(index, TokenType.Number, n, "");
  7952. }
  7953. exports.EOF = new Token(-1, TokenType.Character, 0, "");
  7954. exports.$EOF = 0;
  7955. exports.$TAB = 9;
  7956. exports.$LF = 10;
  7957. exports.$VTAB = 11;
  7958. exports.$FF = 12;
  7959. exports.$CR = 13;
  7960. exports.$SPACE = 32;
  7961. exports.$BANG = 33;
  7962. exports.$DQ = 34;
  7963. exports.$HASH = 35;
  7964. exports.$$ = 36;
  7965. exports.$PERCENT = 37;
  7966. exports.$AMPERSAND = 38;
  7967. exports.$SQ = 39;
  7968. exports.$LPAREN = 40;
  7969. exports.$RPAREN = 41;
  7970. exports.$STAR = 42;
  7971. exports.$PLUS = 43;
  7972. exports.$COMMA = 44;
  7973. exports.$MINUS = 45;
  7974. exports.$PERIOD = 46;
  7975. exports.$SLASH = 47;
  7976. exports.$COLON = 58;
  7977. exports.$SEMICOLON = 59;
  7978. exports.$LT = 60;
  7979. exports.$EQ = 61;
  7980. exports.$GT = 62;
  7981. exports.$QUESTION = 63;
  7982. var $0 = 48;
  7983. var $9 = 57;
  7984. var $A = 65, $E = 69, $Z = 90;
  7985. exports.$LBRACKET = 91;
  7986. exports.$BACKSLASH = 92;
  7987. exports.$RBRACKET = 93;
  7988. var $CARET = 94;
  7989. var $_ = 95;
  7990. var $a = 97, $e = 101, $f = 102, $n = 110, $r = 114, $t = 116, $u = 117, $v = 118, $z = 122;
  7991. exports.$LBRACE = 123;
  7992. exports.$BAR = 124;
  7993. exports.$RBRACE = 125;
  7994. var $NBSP = 160;
  7995. var ScannerError = (function (_super) {
  7996. __extends(ScannerError, _super);
  7997. function ScannerError(message) {
  7998. _super.call(this);
  7999. this.message = message;
  8000. }
  8001. ScannerError.prototype.toString = function () { return this.message; };
  8002. return ScannerError;
  8003. })(exceptions_1.BaseException);
  8004. exports.ScannerError = ScannerError;
  8005. var _Scanner = (function () {
  8006. function _Scanner(input) {
  8007. this.input = input;
  8008. this.peek = 0;
  8009. this.index = -1;
  8010. this.length = input.length;
  8011. this.advance();
  8012. }
  8013. _Scanner.prototype.advance = function () {
  8014. this.peek =
  8015. ++this.index >= this.length ? exports.$EOF : lang_1.StringWrapper.charCodeAt(this.input, this.index);
  8016. };
  8017. _Scanner.prototype.scanToken = function () {
  8018. var input = this.input, length = this.length, peek = this.peek, index = this.index;
  8019. // Skip whitespace.
  8020. while (peek <= exports.$SPACE) {
  8021. if (++index >= length) {
  8022. peek = exports.$EOF;
  8023. break;
  8024. }
  8025. else {
  8026. peek = lang_1.StringWrapper.charCodeAt(input, index);
  8027. }
  8028. }
  8029. this.peek = peek;
  8030. this.index = index;
  8031. if (index >= length) {
  8032. return null;
  8033. }
  8034. // Handle identifiers and numbers.
  8035. if (isIdentifierStart(peek))
  8036. return this.scanIdentifier();
  8037. if (isDigit(peek))
  8038. return this.scanNumber(index);
  8039. var start = index;
  8040. switch (peek) {
  8041. case exports.$PERIOD:
  8042. this.advance();
  8043. return isDigit(this.peek) ? this.scanNumber(start) : newCharacterToken(start, exports.$PERIOD);
  8044. case exports.$LPAREN:
  8045. case exports.$RPAREN:
  8046. case exports.$LBRACE:
  8047. case exports.$RBRACE:
  8048. case exports.$LBRACKET:
  8049. case exports.$RBRACKET:
  8050. case exports.$COMMA:
  8051. case exports.$COLON:
  8052. case exports.$SEMICOLON:
  8053. return this.scanCharacter(start, peek);
  8054. case exports.$SQ:
  8055. case exports.$DQ:
  8056. return this.scanString();
  8057. case exports.$HASH:
  8058. case exports.$PLUS:
  8059. case exports.$MINUS:
  8060. case exports.$STAR:
  8061. case exports.$SLASH:
  8062. case exports.$PERCENT:
  8063. case $CARET:
  8064. return this.scanOperator(start, lang_1.StringWrapper.fromCharCode(peek));
  8065. case exports.$QUESTION:
  8066. return this.scanComplexOperator(start, '?', exports.$PERIOD, '.');
  8067. case exports.$LT:
  8068. case exports.$GT:
  8069. return this.scanComplexOperator(start, lang_1.StringWrapper.fromCharCode(peek), exports.$EQ, '=');
  8070. case exports.$BANG:
  8071. case exports.$EQ:
  8072. return this.scanComplexOperator(start, lang_1.StringWrapper.fromCharCode(peek), exports.$EQ, '=', exports.$EQ, '=');
  8073. case exports.$AMPERSAND:
  8074. return this.scanComplexOperator(start, '&', exports.$AMPERSAND, '&');
  8075. case exports.$BAR:
  8076. return this.scanComplexOperator(start, '|', exports.$BAR, '|');
  8077. case $NBSP:
  8078. while (isWhitespace(this.peek))
  8079. this.advance();
  8080. return this.scanToken();
  8081. }
  8082. this.error("Unexpected character [" + lang_1.StringWrapper.fromCharCode(peek) + "]", 0);
  8083. return null;
  8084. };
  8085. _Scanner.prototype.scanCharacter = function (start, code) {
  8086. assert(this.peek == code);
  8087. this.advance();
  8088. return newCharacterToken(start, code);
  8089. };
  8090. _Scanner.prototype.scanOperator = function (start, str) {
  8091. assert(this.peek == lang_1.StringWrapper.charCodeAt(str, 0));
  8092. assert(collection_1.SetWrapper.has(OPERATORS, str));
  8093. this.advance();
  8094. return newOperatorToken(start, str);
  8095. };
  8096. /**
  8097. * Tokenize a 2/3 char long operator
  8098. *
  8099. * @param start start index in the expression
  8100. * @param one first symbol (always part of the operator)
  8101. * @param twoCode code point for the second symbol
  8102. * @param two second symbol (part of the operator when the second code point matches)
  8103. * @param threeCode code point for the third symbol
  8104. * @param three third symbol (part of the operator when provided and matches source expression)
  8105. * @returns {Token}
  8106. */
  8107. _Scanner.prototype.scanComplexOperator = function (start, one, twoCode, two, threeCode, three) {
  8108. assert(this.peek == lang_1.StringWrapper.charCodeAt(one, 0));
  8109. this.advance();
  8110. var str = one;
  8111. if (this.peek == twoCode) {
  8112. this.advance();
  8113. str += two;
  8114. }
  8115. if (lang_1.isPresent(threeCode) && this.peek == threeCode) {
  8116. this.advance();
  8117. str += three;
  8118. }
  8119. assert(collection_1.SetWrapper.has(OPERATORS, str));
  8120. return newOperatorToken(start, str);
  8121. };
  8122. _Scanner.prototype.scanIdentifier = function () {
  8123. assert(isIdentifierStart(this.peek));
  8124. var start = this.index;
  8125. this.advance();
  8126. while (isIdentifierPart(this.peek))
  8127. this.advance();
  8128. var str = this.input.substring(start, this.index);
  8129. if (collection_1.SetWrapper.has(KEYWORDS, str)) {
  8130. return newKeywordToken(start, str);
  8131. }
  8132. else {
  8133. return newIdentifierToken(start, str);
  8134. }
  8135. };
  8136. _Scanner.prototype.scanNumber = function (start) {
  8137. assert(isDigit(this.peek));
  8138. var simple = (this.index === start);
  8139. this.advance(); // Skip initial digit.
  8140. while (true) {
  8141. if (isDigit(this.peek)) {
  8142. }
  8143. else if (this.peek == exports.$PERIOD) {
  8144. simple = false;
  8145. }
  8146. else if (isExponentStart(this.peek)) {
  8147. this.advance();
  8148. if (isExponentSign(this.peek))
  8149. this.advance();
  8150. if (!isDigit(this.peek))
  8151. this.error('Invalid exponent', -1);
  8152. simple = false;
  8153. }
  8154. else {
  8155. break;
  8156. }
  8157. this.advance();
  8158. }
  8159. var str = this.input.substring(start, this.index);
  8160. // TODO
  8161. var value = simple ? lang_1.NumberWrapper.parseIntAutoRadix(str) : lang_1.NumberWrapper.parseFloat(str);
  8162. return newNumberToken(start, value);
  8163. };
  8164. _Scanner.prototype.scanString = function () {
  8165. assert(this.peek == exports.$SQ || this.peek == exports.$DQ);
  8166. var start = this.index;
  8167. var quote = this.peek;
  8168. this.advance(); // Skip initial quote.
  8169. var buffer;
  8170. var marker = this.index;
  8171. var input = this.input;
  8172. while (this.peek != quote) {
  8173. if (this.peek == exports.$BACKSLASH) {
  8174. if (buffer == null)
  8175. buffer = new lang_1.StringJoiner();
  8176. buffer.add(input.substring(marker, this.index));
  8177. this.advance();
  8178. var unescapedCode;
  8179. if (this.peek == $u) {
  8180. // 4 character hex code for unicode character.
  8181. var hex = input.substring(this.index + 1, this.index + 5);
  8182. try {
  8183. unescapedCode = lang_1.NumberWrapper.parseInt(hex, 16);
  8184. }
  8185. catch (e) {
  8186. this.error("Invalid unicode escape [\\u" + hex + "]", 0);
  8187. }
  8188. for (var i = 0; i < 5; i++) {
  8189. this.advance();
  8190. }
  8191. }
  8192. else {
  8193. unescapedCode = unescape(this.peek);
  8194. this.advance();
  8195. }
  8196. buffer.add(lang_1.StringWrapper.fromCharCode(unescapedCode));
  8197. marker = this.index;
  8198. }
  8199. else if (this.peek == exports.$EOF) {
  8200. this.error('Unterminated quote', 0);
  8201. }
  8202. else {
  8203. this.advance();
  8204. }
  8205. }
  8206. var last = input.substring(marker, this.index);
  8207. this.advance(); // Skip terminating quote.
  8208. // Compute the unescaped string value.
  8209. var unescaped = last;
  8210. if (buffer != null) {
  8211. buffer.add(last);
  8212. unescaped = buffer.toString();
  8213. }
  8214. return newStringToken(start, unescaped);
  8215. };
  8216. _Scanner.prototype.error = function (message, offset) {
  8217. var position = this.index + offset;
  8218. throw new ScannerError("Lexer Error: " + message + " at column " + position + " in expression [" + this.input + "]");
  8219. };
  8220. return _Scanner;
  8221. })();
  8222. function isWhitespace(code) {
  8223. return (code >= exports.$TAB && code <= exports.$SPACE) || (code == $NBSP);
  8224. }
  8225. function isIdentifierStart(code) {
  8226. return ($a <= code && code <= $z) || ($A <= code && code <= $Z) || (code == $_) || (code == exports.$$);
  8227. }
  8228. function isIdentifier(input) {
  8229. if (input.length == 0)
  8230. return false;
  8231. var scanner = new _Scanner(input);
  8232. if (!isIdentifierStart(scanner.peek))
  8233. return false;
  8234. scanner.advance();
  8235. while (scanner.peek !== exports.$EOF) {
  8236. if (!isIdentifierPart(scanner.peek))
  8237. return false;
  8238. scanner.advance();
  8239. }
  8240. return true;
  8241. }
  8242. exports.isIdentifier = isIdentifier;
  8243. function isIdentifierPart(code) {
  8244. return ($a <= code && code <= $z) || ($A <= code && code <= $Z) || ($0 <= code && code <= $9) ||
  8245. (code == $_) || (code == exports.$$);
  8246. }
  8247. function isDigit(code) {
  8248. return $0 <= code && code <= $9;
  8249. }
  8250. function isExponentStart(code) {
  8251. return code == $e || code == $E;
  8252. }
  8253. function isExponentSign(code) {
  8254. return code == exports.$MINUS || code == exports.$PLUS;
  8255. }
  8256. function unescape(code) {
  8257. switch (code) {
  8258. case $n:
  8259. return exports.$LF;
  8260. case $f:
  8261. return exports.$FF;
  8262. case $r:
  8263. return exports.$CR;
  8264. case $t:
  8265. return exports.$TAB;
  8266. case $v:
  8267. return exports.$VTAB;
  8268. default:
  8269. return code;
  8270. }
  8271. }
  8272. var OPERATORS = collection_1.SetWrapper.createFromList([
  8273. '+',
  8274. '-',
  8275. '*',
  8276. '/',
  8277. '%',
  8278. '^',
  8279. '=',
  8280. '==',
  8281. '!=',
  8282. '===',
  8283. '!==',
  8284. '<',
  8285. '>',
  8286. '<=',
  8287. '>=',
  8288. '&&',
  8289. '||',
  8290. '&',
  8291. '|',
  8292. '!',
  8293. '?',
  8294. '#',
  8295. '?.'
  8296. ]);
  8297. var KEYWORDS = collection_1.SetWrapper.createFromList(['var', 'null', 'undefined', 'true', 'false', 'if', 'else']);
  8298. /***/ },
  8299. /* 32 */
  8300. /***/ function(module, exports, __webpack_require__) {
  8301. var __extends = (this && this.__extends) || function (d, b) {
  8302. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  8303. function __() { this.constructor = d; }
  8304. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8305. };
  8306. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  8307. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  8308. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  8309. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  8310. return c > 3 && r && Object.defineProperty(target, key, r), r;
  8311. };
  8312. var __metadata = (this && this.__metadata) || function (k, v) {
  8313. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  8314. };
  8315. var decorators_1 = __webpack_require__(8);
  8316. var lang_1 = __webpack_require__(5);
  8317. var exceptions_1 = __webpack_require__(14);
  8318. var collection_1 = __webpack_require__(12);
  8319. var lexer_1 = __webpack_require__(31);
  8320. var reflection_1 = __webpack_require__(16);
  8321. var ast_1 = __webpack_require__(30);
  8322. var _implicitReceiver = new ast_1.ImplicitReceiver();
  8323. // TODO(tbosch): Cannot make this const/final right now because of the transpiler...
  8324. var INTERPOLATION_REGEXP = /\{\{(.*?)\}\}/g;
  8325. var ParseException = (function (_super) {
  8326. __extends(ParseException, _super);
  8327. function ParseException(message, input, errLocation, ctxLocation) {
  8328. _super.call(this, "Parser Error: " + message + " " + errLocation + " [" + input + "] in " + ctxLocation);
  8329. }
  8330. return ParseException;
  8331. })(exceptions_1.BaseException);
  8332. var Parser = (function () {
  8333. function Parser(/** @internal */ _lexer, providedReflector) {
  8334. if (providedReflector === void 0) { providedReflector = null; }
  8335. this._lexer = _lexer;
  8336. this._reflector = lang_1.isPresent(providedReflector) ? providedReflector : reflection_1.reflector;
  8337. }
  8338. Parser.prototype.parseAction = function (input, location) {
  8339. this._checkNoInterpolation(input, location);
  8340. var tokens = this._lexer.tokenize(input);
  8341. var ast = new _ParseAST(input, location, tokens, this._reflector, true).parseChain();
  8342. return new ast_1.ASTWithSource(ast, input, location);
  8343. };
  8344. Parser.prototype.parseBinding = function (input, location) {
  8345. var ast = this._parseBindingAst(input, location);
  8346. return new ast_1.ASTWithSource(ast, input, location);
  8347. };
  8348. Parser.prototype.parseSimpleBinding = function (input, location) {
  8349. var ast = this._parseBindingAst(input, location);
  8350. if (!SimpleExpressionChecker.check(ast)) {
  8351. throw new ParseException('Host binding expression can only contain field access and constants', input, location);
  8352. }
  8353. return new ast_1.ASTWithSource(ast, input, location);
  8354. };
  8355. Parser.prototype._parseBindingAst = function (input, location) {
  8356. // Quotes expressions use 3rd-party expression language. We don't want to use
  8357. // our lexer or parser for that, so we check for that ahead of time.
  8358. var quote = this._parseQuote(input, location);
  8359. if (lang_1.isPresent(quote)) {
  8360. return quote;
  8361. }
  8362. this._checkNoInterpolation(input, location);
  8363. var tokens = this._lexer.tokenize(input);
  8364. return new _ParseAST(input, location, tokens, this._reflector, false).parseChain();
  8365. };
  8366. Parser.prototype._parseQuote = function (input, location) {
  8367. if (lang_1.isBlank(input))
  8368. return null;
  8369. var prefixSeparatorIndex = input.indexOf(':');
  8370. if (prefixSeparatorIndex == -1)
  8371. return null;
  8372. var prefix = input.substring(0, prefixSeparatorIndex).trim();
  8373. if (!lexer_1.isIdentifier(prefix))
  8374. return null;
  8375. var uninterpretedExpression = input.substring(prefixSeparatorIndex + 1);
  8376. return new ast_1.Quote(prefix, uninterpretedExpression, location);
  8377. };
  8378. Parser.prototype.parseTemplateBindings = function (input, location) {
  8379. var tokens = this._lexer.tokenize(input);
  8380. return new _ParseAST(input, location, tokens, this._reflector, false).parseTemplateBindings();
  8381. };
  8382. Parser.prototype.parseInterpolation = function (input, location) {
  8383. var parts = lang_1.StringWrapper.split(input, INTERPOLATION_REGEXP);
  8384. if (parts.length <= 1) {
  8385. return null;
  8386. }
  8387. var strings = [];
  8388. var expressions = [];
  8389. for (var i = 0; i < parts.length; i++) {
  8390. var part = parts[i];
  8391. if (i % 2 === 0) {
  8392. // fixed string
  8393. strings.push(part);
  8394. }
  8395. else if (part.trim().length > 0) {
  8396. var tokens = this._lexer.tokenize(part);
  8397. var ast = new _ParseAST(input, location, tokens, this._reflector, false).parseChain();
  8398. expressions.push(ast);
  8399. }
  8400. else {
  8401. throw new ParseException('Blank expressions are not allowed in interpolated strings', input, "at column " + this._findInterpolationErrorColumn(parts, i) + " in", location);
  8402. }
  8403. }
  8404. return new ast_1.ASTWithSource(new ast_1.Interpolation(strings, expressions), input, location);
  8405. };
  8406. Parser.prototype.wrapLiteralPrimitive = function (input, location) {
  8407. return new ast_1.ASTWithSource(new ast_1.LiteralPrimitive(input), input, location);
  8408. };
  8409. Parser.prototype._checkNoInterpolation = function (input, location) {
  8410. var parts = lang_1.StringWrapper.split(input, INTERPOLATION_REGEXP);
  8411. if (parts.length > 1) {
  8412. throw new ParseException('Got interpolation ({{}}) where expression was expected', input, "at column " + this._findInterpolationErrorColumn(parts, 1) + " in", location);
  8413. }
  8414. };
  8415. Parser.prototype._findInterpolationErrorColumn = function (parts, partInErrIdx) {
  8416. var errLocation = '';
  8417. for (var j = 0; j < partInErrIdx; j++) {
  8418. errLocation += j % 2 === 0 ? parts[j] : "{{" + parts[j] + "}}";
  8419. }
  8420. return errLocation.length;
  8421. };
  8422. Parser = __decorate([
  8423. decorators_1.Injectable(),
  8424. __metadata('design:paramtypes', [lexer_1.Lexer, reflection_1.Reflector])
  8425. ], Parser);
  8426. return Parser;
  8427. })();
  8428. exports.Parser = Parser;
  8429. var _ParseAST = (function () {
  8430. function _ParseAST(input, location, tokens, reflector, parseAction) {
  8431. this.input = input;
  8432. this.location = location;
  8433. this.tokens = tokens;
  8434. this.reflector = reflector;
  8435. this.parseAction = parseAction;
  8436. this.index = 0;
  8437. }
  8438. _ParseAST.prototype.peek = function (offset) {
  8439. var i = this.index + offset;
  8440. return i < this.tokens.length ? this.tokens[i] : lexer_1.EOF;
  8441. };
  8442. Object.defineProperty(_ParseAST.prototype, "next", {
  8443. get: function () { return this.peek(0); },
  8444. enumerable: true,
  8445. configurable: true
  8446. });
  8447. Object.defineProperty(_ParseAST.prototype, "inputIndex", {
  8448. get: function () {
  8449. return (this.index < this.tokens.length) ? this.next.index : this.input.length;
  8450. },
  8451. enumerable: true,
  8452. configurable: true
  8453. });
  8454. _ParseAST.prototype.advance = function () { this.index++; };
  8455. _ParseAST.prototype.optionalCharacter = function (code) {
  8456. if (this.next.isCharacter(code)) {
  8457. this.advance();
  8458. return true;
  8459. }
  8460. else {
  8461. return false;
  8462. }
  8463. };
  8464. _ParseAST.prototype.optionalKeywordVar = function () {
  8465. if (this.peekKeywordVar()) {
  8466. this.advance();
  8467. return true;
  8468. }
  8469. else {
  8470. return false;
  8471. }
  8472. };
  8473. _ParseAST.prototype.peekKeywordVar = function () { return this.next.isKeywordVar() || this.next.isOperator('#'); };
  8474. _ParseAST.prototype.expectCharacter = function (code) {
  8475. if (this.optionalCharacter(code))
  8476. return;
  8477. this.error("Missing expected " + lang_1.StringWrapper.fromCharCode(code));
  8478. };
  8479. _ParseAST.prototype.optionalOperator = function (op) {
  8480. if (this.next.isOperator(op)) {
  8481. this.advance();
  8482. return true;
  8483. }
  8484. else {
  8485. return false;
  8486. }
  8487. };
  8488. _ParseAST.prototype.expectOperator = function (operator) {
  8489. if (this.optionalOperator(operator))
  8490. return;
  8491. this.error("Missing expected operator " + operator);
  8492. };
  8493. _ParseAST.prototype.expectIdentifierOrKeyword = function () {
  8494. var n = this.next;
  8495. if (!n.isIdentifier() && !n.isKeyword()) {
  8496. this.error("Unexpected token " + n + ", expected identifier or keyword");
  8497. }
  8498. this.advance();
  8499. return n.toString();
  8500. };
  8501. _ParseAST.prototype.expectIdentifierOrKeywordOrString = function () {
  8502. var n = this.next;
  8503. if (!n.isIdentifier() && !n.isKeyword() && !n.isString()) {
  8504. this.error("Unexpected token " + n + ", expected identifier, keyword, or string");
  8505. }
  8506. this.advance();
  8507. return n.toString();
  8508. };
  8509. _ParseAST.prototype.parseChain = function () {
  8510. var exprs = [];
  8511. while (this.index < this.tokens.length) {
  8512. var expr = this.parsePipe();
  8513. exprs.push(expr);
  8514. if (this.optionalCharacter(lexer_1.$SEMICOLON)) {
  8515. if (!this.parseAction) {
  8516. this.error("Binding expression cannot contain chained expression");
  8517. }
  8518. while (this.optionalCharacter(lexer_1.$SEMICOLON)) {
  8519. } // read all semicolons
  8520. }
  8521. else if (this.index < this.tokens.length) {
  8522. this.error("Unexpected token '" + this.next + "'");
  8523. }
  8524. }
  8525. if (exprs.length == 0)
  8526. return new ast_1.EmptyExpr();
  8527. if (exprs.length == 1)
  8528. return exprs[0];
  8529. return new ast_1.Chain(exprs);
  8530. };
  8531. _ParseAST.prototype.parsePipe = function () {
  8532. var result = this.parseExpression();
  8533. if (this.optionalOperator("|")) {
  8534. if (this.parseAction) {
  8535. this.error("Cannot have a pipe in an action expression");
  8536. }
  8537. do {
  8538. var name = this.expectIdentifierOrKeyword();
  8539. var args = [];
  8540. while (this.optionalCharacter(lexer_1.$COLON)) {
  8541. args.push(this.parseExpression());
  8542. }
  8543. result = new ast_1.BindingPipe(result, name, args);
  8544. } while (this.optionalOperator("|"));
  8545. }
  8546. return result;
  8547. };
  8548. _ParseAST.prototype.parseExpression = function () { return this.parseConditional(); };
  8549. _ParseAST.prototype.parseConditional = function () {
  8550. var start = this.inputIndex;
  8551. var result = this.parseLogicalOr();
  8552. if (this.optionalOperator('?')) {
  8553. var yes = this.parsePipe();
  8554. if (!this.optionalCharacter(lexer_1.$COLON)) {
  8555. var end = this.inputIndex;
  8556. var expression = this.input.substring(start, end);
  8557. this.error("Conditional expression " + expression + " requires all 3 expressions");
  8558. }
  8559. var no = this.parsePipe();
  8560. return new ast_1.Conditional(result, yes, no);
  8561. }
  8562. else {
  8563. return result;
  8564. }
  8565. };
  8566. _ParseAST.prototype.parseLogicalOr = function () {
  8567. // '||'
  8568. var result = this.parseLogicalAnd();
  8569. while (this.optionalOperator('||')) {
  8570. result = new ast_1.Binary('||', result, this.parseLogicalAnd());
  8571. }
  8572. return result;
  8573. };
  8574. _ParseAST.prototype.parseLogicalAnd = function () {
  8575. // '&&'
  8576. var result = this.parseEquality();
  8577. while (this.optionalOperator('&&')) {
  8578. result = new ast_1.Binary('&&', result, this.parseEquality());
  8579. }
  8580. return result;
  8581. };
  8582. _ParseAST.prototype.parseEquality = function () {
  8583. // '==','!=','===','!=='
  8584. var result = this.parseRelational();
  8585. while (true) {
  8586. if (this.optionalOperator('==')) {
  8587. result = new ast_1.Binary('==', result, this.parseRelational());
  8588. }
  8589. else if (this.optionalOperator('===')) {
  8590. result = new ast_1.Binary('===', result, this.parseRelational());
  8591. }
  8592. else if (this.optionalOperator('!=')) {
  8593. result = new ast_1.Binary('!=', result, this.parseRelational());
  8594. }
  8595. else if (this.optionalOperator('!==')) {
  8596. result = new ast_1.Binary('!==', result, this.parseRelational());
  8597. }
  8598. else {
  8599. return result;
  8600. }
  8601. }
  8602. };
  8603. _ParseAST.prototype.parseRelational = function () {
  8604. // '<', '>', '<=', '>='
  8605. var result = this.parseAdditive();
  8606. while (true) {
  8607. if (this.optionalOperator('<')) {
  8608. result = new ast_1.Binary('<', result, this.parseAdditive());
  8609. }
  8610. else if (this.optionalOperator('>')) {
  8611. result = new ast_1.Binary('>', result, this.parseAdditive());
  8612. }
  8613. else if (this.optionalOperator('<=')) {
  8614. result = new ast_1.Binary('<=', result, this.parseAdditive());
  8615. }
  8616. else if (this.optionalOperator('>=')) {
  8617. result = new ast_1.Binary('>=', result, this.parseAdditive());
  8618. }
  8619. else {
  8620. return result;
  8621. }
  8622. }
  8623. };
  8624. _ParseAST.prototype.parseAdditive = function () {
  8625. // '+', '-'
  8626. var result = this.parseMultiplicative();
  8627. while (true) {
  8628. if (this.optionalOperator('+')) {
  8629. result = new ast_1.Binary('+', result, this.parseMultiplicative());
  8630. }
  8631. else if (this.optionalOperator('-')) {
  8632. result = new ast_1.Binary('-', result, this.parseMultiplicative());
  8633. }
  8634. else {
  8635. return result;
  8636. }
  8637. }
  8638. };
  8639. _ParseAST.prototype.parseMultiplicative = function () {
  8640. // '*', '%', '/'
  8641. var result = this.parsePrefix();
  8642. while (true) {
  8643. if (this.optionalOperator('*')) {
  8644. result = new ast_1.Binary('*', result, this.parsePrefix());
  8645. }
  8646. else if (this.optionalOperator('%')) {
  8647. result = new ast_1.Binary('%', result, this.parsePrefix());
  8648. }
  8649. else if (this.optionalOperator('/')) {
  8650. result = new ast_1.Binary('/', result, this.parsePrefix());
  8651. }
  8652. else {
  8653. return result;
  8654. }
  8655. }
  8656. };
  8657. _ParseAST.prototype.parsePrefix = function () {
  8658. if (this.optionalOperator('+')) {
  8659. return this.parsePrefix();
  8660. }
  8661. else if (this.optionalOperator('-')) {
  8662. return new ast_1.Binary('-', new ast_1.LiteralPrimitive(0), this.parsePrefix());
  8663. }
  8664. else if (this.optionalOperator('!')) {
  8665. return new ast_1.PrefixNot(this.parsePrefix());
  8666. }
  8667. else {
  8668. return this.parseCallChain();
  8669. }
  8670. };
  8671. _ParseAST.prototype.parseCallChain = function () {
  8672. var result = this.parsePrimary();
  8673. while (true) {
  8674. if (this.optionalCharacter(lexer_1.$PERIOD)) {
  8675. result = this.parseAccessMemberOrMethodCall(result, false);
  8676. }
  8677. else if (this.optionalOperator('?.')) {
  8678. result = this.parseAccessMemberOrMethodCall(result, true);
  8679. }
  8680. else if (this.optionalCharacter(lexer_1.$LBRACKET)) {
  8681. var key = this.parsePipe();
  8682. this.expectCharacter(lexer_1.$RBRACKET);
  8683. if (this.optionalOperator("=")) {
  8684. var value = this.parseConditional();
  8685. result = new ast_1.KeyedWrite(result, key, value);
  8686. }
  8687. else {
  8688. result = new ast_1.KeyedRead(result, key);
  8689. }
  8690. }
  8691. else if (this.optionalCharacter(lexer_1.$LPAREN)) {
  8692. var args = this.parseCallArguments();
  8693. this.expectCharacter(lexer_1.$RPAREN);
  8694. result = new ast_1.FunctionCall(result, args);
  8695. }
  8696. else {
  8697. return result;
  8698. }
  8699. }
  8700. };
  8701. _ParseAST.prototype.parsePrimary = function () {
  8702. if (this.optionalCharacter(lexer_1.$LPAREN)) {
  8703. var result = this.parsePipe();
  8704. this.expectCharacter(lexer_1.$RPAREN);
  8705. return result;
  8706. }
  8707. else if (this.next.isKeywordNull() || this.next.isKeywordUndefined()) {
  8708. this.advance();
  8709. return new ast_1.LiteralPrimitive(null);
  8710. }
  8711. else if (this.next.isKeywordTrue()) {
  8712. this.advance();
  8713. return new ast_1.LiteralPrimitive(true);
  8714. }
  8715. else if (this.next.isKeywordFalse()) {
  8716. this.advance();
  8717. return new ast_1.LiteralPrimitive(false);
  8718. }
  8719. else if (this.optionalCharacter(lexer_1.$LBRACKET)) {
  8720. var elements = this.parseExpressionList(lexer_1.$RBRACKET);
  8721. this.expectCharacter(lexer_1.$RBRACKET);
  8722. return new ast_1.LiteralArray(elements);
  8723. }
  8724. else if (this.next.isCharacter(lexer_1.$LBRACE)) {
  8725. return this.parseLiteralMap();
  8726. }
  8727. else if (this.next.isIdentifier()) {
  8728. return this.parseAccessMemberOrMethodCall(_implicitReceiver, false);
  8729. }
  8730. else if (this.next.isNumber()) {
  8731. var value = this.next.toNumber();
  8732. this.advance();
  8733. return new ast_1.LiteralPrimitive(value);
  8734. }
  8735. else if (this.next.isString()) {
  8736. var literalValue = this.next.toString();
  8737. this.advance();
  8738. return new ast_1.LiteralPrimitive(literalValue);
  8739. }
  8740. else if (this.index >= this.tokens.length) {
  8741. this.error("Unexpected end of expression: " + this.input);
  8742. }
  8743. else {
  8744. this.error("Unexpected token " + this.next);
  8745. }
  8746. // error() throws, so we don't reach here.
  8747. throw new exceptions_1.BaseException("Fell through all cases in parsePrimary");
  8748. };
  8749. _ParseAST.prototype.parseExpressionList = function (terminator) {
  8750. var result = [];
  8751. if (!this.next.isCharacter(terminator)) {
  8752. do {
  8753. result.push(this.parsePipe());
  8754. } while (this.optionalCharacter(lexer_1.$COMMA));
  8755. }
  8756. return result;
  8757. };
  8758. _ParseAST.prototype.parseLiteralMap = function () {
  8759. var keys = [];
  8760. var values = [];
  8761. this.expectCharacter(lexer_1.$LBRACE);
  8762. if (!this.optionalCharacter(lexer_1.$RBRACE)) {
  8763. do {
  8764. var key = this.expectIdentifierOrKeywordOrString();
  8765. keys.push(key);
  8766. this.expectCharacter(lexer_1.$COLON);
  8767. values.push(this.parsePipe());
  8768. } while (this.optionalCharacter(lexer_1.$COMMA));
  8769. this.expectCharacter(lexer_1.$RBRACE);
  8770. }
  8771. return new ast_1.LiteralMap(keys, values);
  8772. };
  8773. _ParseAST.prototype.parseAccessMemberOrMethodCall = function (receiver, isSafe) {
  8774. if (isSafe === void 0) { isSafe = false; }
  8775. var id = this.expectIdentifierOrKeyword();
  8776. if (this.optionalCharacter(lexer_1.$LPAREN)) {
  8777. var args = this.parseCallArguments();
  8778. this.expectCharacter(lexer_1.$RPAREN);
  8779. var fn = this.reflector.method(id);
  8780. return isSafe ? new ast_1.SafeMethodCall(receiver, id, fn, args) :
  8781. new ast_1.MethodCall(receiver, id, fn, args);
  8782. }
  8783. else {
  8784. if (isSafe) {
  8785. if (this.optionalOperator("=")) {
  8786. this.error("The '?.' operator cannot be used in the assignment");
  8787. }
  8788. else {
  8789. return new ast_1.SafePropertyRead(receiver, id, this.reflector.getter(id));
  8790. }
  8791. }
  8792. else {
  8793. if (this.optionalOperator("=")) {
  8794. if (!this.parseAction) {
  8795. this.error("Bindings cannot contain assignments");
  8796. }
  8797. var value = this.parseConditional();
  8798. return new ast_1.PropertyWrite(receiver, id, this.reflector.setter(id), value);
  8799. }
  8800. else {
  8801. return new ast_1.PropertyRead(receiver, id, this.reflector.getter(id));
  8802. }
  8803. }
  8804. }
  8805. return null;
  8806. };
  8807. _ParseAST.prototype.parseCallArguments = function () {
  8808. if (this.next.isCharacter(lexer_1.$RPAREN))
  8809. return [];
  8810. var positionals = [];
  8811. do {
  8812. positionals.push(this.parsePipe());
  8813. } while (this.optionalCharacter(lexer_1.$COMMA));
  8814. return positionals;
  8815. };
  8816. _ParseAST.prototype.parseBlockContent = function () {
  8817. if (!this.parseAction) {
  8818. this.error("Binding expression cannot contain chained expression");
  8819. }
  8820. var exprs = [];
  8821. while (this.index < this.tokens.length && !this.next.isCharacter(lexer_1.$RBRACE)) {
  8822. var expr = this.parseExpression();
  8823. exprs.push(expr);
  8824. if (this.optionalCharacter(lexer_1.$SEMICOLON)) {
  8825. while (this.optionalCharacter(lexer_1.$SEMICOLON)) {
  8826. } // read all semicolons
  8827. }
  8828. }
  8829. if (exprs.length == 0)
  8830. return new ast_1.EmptyExpr();
  8831. if (exprs.length == 1)
  8832. return exprs[0];
  8833. return new ast_1.Chain(exprs);
  8834. };
  8835. /**
  8836. * An identifier, a keyword, a string with an optional `-` inbetween.
  8837. */
  8838. _ParseAST.prototype.expectTemplateBindingKey = function () {
  8839. var result = '';
  8840. var operatorFound = false;
  8841. do {
  8842. result += this.expectIdentifierOrKeywordOrString();
  8843. operatorFound = this.optionalOperator('-');
  8844. if (operatorFound) {
  8845. result += '-';
  8846. }
  8847. } while (operatorFound);
  8848. return result.toString();
  8849. };
  8850. _ParseAST.prototype.parseTemplateBindings = function () {
  8851. var bindings = [];
  8852. var prefix = null;
  8853. while (this.index < this.tokens.length) {
  8854. var keyIsVar = this.optionalKeywordVar();
  8855. var key = this.expectTemplateBindingKey();
  8856. if (!keyIsVar) {
  8857. if (prefix == null) {
  8858. prefix = key;
  8859. }
  8860. else {
  8861. key = prefix + key[0].toUpperCase() + key.substring(1);
  8862. }
  8863. }
  8864. this.optionalCharacter(lexer_1.$COLON);
  8865. var name = null;
  8866. var expression = null;
  8867. if (keyIsVar) {
  8868. if (this.optionalOperator("=")) {
  8869. name = this.expectTemplateBindingKey();
  8870. }
  8871. else {
  8872. name = '\$implicit';
  8873. }
  8874. }
  8875. else if (this.next !== lexer_1.EOF && !this.peekKeywordVar()) {
  8876. var start = this.inputIndex;
  8877. var ast = this.parsePipe();
  8878. var source = this.input.substring(start, this.inputIndex);
  8879. expression = new ast_1.ASTWithSource(ast, source, this.location);
  8880. }
  8881. bindings.push(new ast_1.TemplateBinding(key, keyIsVar, name, expression));
  8882. if (!this.optionalCharacter(lexer_1.$SEMICOLON)) {
  8883. this.optionalCharacter(lexer_1.$COMMA);
  8884. }
  8885. }
  8886. return bindings;
  8887. };
  8888. _ParseAST.prototype.error = function (message, index) {
  8889. if (index === void 0) { index = null; }
  8890. if (lang_1.isBlank(index))
  8891. index = this.index;
  8892. var location = (index < this.tokens.length) ? "at column " + (this.tokens[index].index + 1) + " in" :
  8893. "at the end of the expression";
  8894. throw new ParseException(message, this.input, location, this.location);
  8895. };
  8896. return _ParseAST;
  8897. })();
  8898. exports._ParseAST = _ParseAST;
  8899. var SimpleExpressionChecker = (function () {
  8900. function SimpleExpressionChecker() {
  8901. this.simple = true;
  8902. }
  8903. SimpleExpressionChecker.check = function (ast) {
  8904. var s = new SimpleExpressionChecker();
  8905. ast.visit(s);
  8906. return s.simple;
  8907. };
  8908. SimpleExpressionChecker.prototype.visitImplicitReceiver = function (ast) { };
  8909. SimpleExpressionChecker.prototype.visitInterpolation = function (ast) { this.simple = false; };
  8910. SimpleExpressionChecker.prototype.visitLiteralPrimitive = function (ast) { };
  8911. SimpleExpressionChecker.prototype.visitPropertyRead = function (ast) { };
  8912. SimpleExpressionChecker.prototype.visitPropertyWrite = function (ast) { this.simple = false; };
  8913. SimpleExpressionChecker.prototype.visitSafePropertyRead = function (ast) { this.simple = false; };
  8914. SimpleExpressionChecker.prototype.visitMethodCall = function (ast) { this.simple = false; };
  8915. SimpleExpressionChecker.prototype.visitSafeMethodCall = function (ast) { this.simple = false; };
  8916. SimpleExpressionChecker.prototype.visitFunctionCall = function (ast) { this.simple = false; };
  8917. SimpleExpressionChecker.prototype.visitLiteralArray = function (ast) { this.visitAll(ast.expressions); };
  8918. SimpleExpressionChecker.prototype.visitLiteralMap = function (ast) { this.visitAll(ast.values); };
  8919. SimpleExpressionChecker.prototype.visitBinary = function (ast) { this.simple = false; };
  8920. SimpleExpressionChecker.prototype.visitPrefixNot = function (ast) { this.simple = false; };
  8921. SimpleExpressionChecker.prototype.visitConditional = function (ast) { this.simple = false; };
  8922. SimpleExpressionChecker.prototype.visitPipe = function (ast) { this.simple = false; };
  8923. SimpleExpressionChecker.prototype.visitKeyedRead = function (ast) { this.simple = false; };
  8924. SimpleExpressionChecker.prototype.visitKeyedWrite = function (ast) { this.simple = false; };
  8925. SimpleExpressionChecker.prototype.visitAll = function (asts) {
  8926. var res = collection_1.ListWrapper.createFixedSize(asts.length);
  8927. for (var i = 0; i < asts.length; ++i) {
  8928. res[i] = asts[i].visit(this);
  8929. }
  8930. return res;
  8931. };
  8932. SimpleExpressionChecker.prototype.visitChain = function (ast) { this.simple = false; };
  8933. SimpleExpressionChecker.prototype.visitQuote = function (ast) { this.simple = false; };
  8934. return SimpleExpressionChecker;
  8935. })();
  8936. /***/ },
  8937. /* 33 */
  8938. /***/ function(module, exports, __webpack_require__) {
  8939. var lang_1 = __webpack_require__(5);
  8940. var exceptions_1 = __webpack_require__(14);
  8941. var collection_1 = __webpack_require__(12);
  8942. var Locals = (function () {
  8943. function Locals(parent, current) {
  8944. this.parent = parent;
  8945. this.current = current;
  8946. }
  8947. Locals.prototype.contains = function (name) {
  8948. if (this.current.has(name)) {
  8949. return true;
  8950. }
  8951. if (lang_1.isPresent(this.parent)) {
  8952. return this.parent.contains(name);
  8953. }
  8954. return false;
  8955. };
  8956. Locals.prototype.get = function (name) {
  8957. if (this.current.has(name)) {
  8958. return this.current.get(name);
  8959. }
  8960. if (lang_1.isPresent(this.parent)) {
  8961. return this.parent.get(name);
  8962. }
  8963. throw new exceptions_1.BaseException("Cannot find '" + name + "'");
  8964. };
  8965. Locals.prototype.set = function (name, value) {
  8966. // TODO(rado): consider removing this check if we can guarantee this is not
  8967. // exposed to the public API.
  8968. // TODO: vsavkin maybe it should check only the local map
  8969. if (this.current.has(name)) {
  8970. this.current.set(name, value);
  8971. }
  8972. else {
  8973. throw new exceptions_1.BaseException("Setting of new keys post-construction is not supported. Key: " + name + ".");
  8974. }
  8975. };
  8976. Locals.prototype.clearValues = function () { collection_1.MapWrapper.clearValues(this.current); };
  8977. return Locals;
  8978. })();
  8979. exports.Locals = Locals;
  8980. /***/ },
  8981. /* 34 */
  8982. /***/ function(module, exports, __webpack_require__) {
  8983. var __extends = (this && this.__extends) || function (d, b) {
  8984. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  8985. function __() { this.constructor = d; }
  8986. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8987. };
  8988. var exceptions_1 = __webpack_require__(14);
  8989. /**
  8990. * An error thrown if application changes model breaking the top-down data flow.
  8991. *
  8992. * This exception is only thrown in dev mode.
  8993. *
  8994. * <!-- TODO: Add a link once the dev mode option is configurable -->
  8995. *
  8996. * ### Example
  8997. *
  8998. * ```typescript
  8999. * @Component({
  9000. * selector: 'parent',
  9001. * template: `
  9002. * <child [prop]="parentProp"></child>
  9003. * `,
  9004. * directives: [forwardRef(() => Child)]
  9005. * })
  9006. * class Parent {
  9007. * parentProp = "init";
  9008. * }
  9009. *
  9010. * @Directive({selector: 'child', inputs: ['prop']})
  9011. * class Child {
  9012. * constructor(public parent: Parent) {}
  9013. *
  9014. * set prop(v) {
  9015. * // this updates the parent property, which is disallowed during change detection
  9016. * // this will result in ExpressionChangedAfterItHasBeenCheckedException
  9017. * this.parent.parentProp = "updated";
  9018. * }
  9019. * }
  9020. * ```
  9021. */
  9022. var ExpressionChangedAfterItHasBeenCheckedException = (function (_super) {
  9023. __extends(ExpressionChangedAfterItHasBeenCheckedException, _super);
  9024. function ExpressionChangedAfterItHasBeenCheckedException(exp, oldValue, currValue, context) {
  9025. _super.call(this, ("Expression '" + exp + "' has changed after it was checked. ") +
  9026. ("Previous value: '" + oldValue + "'. Current value: '" + currValue + "'"));
  9027. }
  9028. return ExpressionChangedAfterItHasBeenCheckedException;
  9029. })(exceptions_1.BaseException);
  9030. exports.ExpressionChangedAfterItHasBeenCheckedException = ExpressionChangedAfterItHasBeenCheckedException;
  9031. /**
  9032. * Thrown when an expression evaluation raises an exception.
  9033. *
  9034. * This error wraps the original exception to attach additional contextual information that can
  9035. * be useful for debugging.
  9036. *
  9037. * ### Example ([live demo](http://plnkr.co/edit/2Kywoz?p=preview))
  9038. *
  9039. * ```typescript
  9040. * @Directive({selector: 'child', inputs: ['prop']})
  9041. * class Child {
  9042. * prop;
  9043. * }
  9044. *
  9045. * @Component({
  9046. * selector: 'app',
  9047. * template: `
  9048. * <child [prop]="field.first"></child>
  9049. * `,
  9050. * directives: [Child]
  9051. * })
  9052. * class App {
  9053. * field = null;
  9054. * }
  9055. *
  9056. * bootstrap(App);
  9057. * ```
  9058. *
  9059. * You can access the original exception and stack through the `originalException` and
  9060. * `originalStack` properties.
  9061. */
  9062. var ChangeDetectionError = (function (_super) {
  9063. __extends(ChangeDetectionError, _super);
  9064. function ChangeDetectionError(exp, originalException, originalStack, context) {
  9065. _super.call(this, originalException + " in [" + exp + "]", originalException, originalStack, context);
  9066. this.location = exp;
  9067. }
  9068. return ChangeDetectionError;
  9069. })(exceptions_1.WrappedException);
  9070. exports.ChangeDetectionError = ChangeDetectionError;
  9071. /**
  9072. * Thrown when change detector executes on dehydrated view.
  9073. *
  9074. * This error indicates a bug in the framework.
  9075. *
  9076. * This is an internal Angular error.
  9077. */
  9078. var DehydratedException = (function (_super) {
  9079. __extends(DehydratedException, _super);
  9080. function DehydratedException() {
  9081. _super.call(this, 'Attempt to detect changes on a dehydrated detector.');
  9082. }
  9083. return DehydratedException;
  9084. })(exceptions_1.BaseException);
  9085. exports.DehydratedException = DehydratedException;
  9086. /***/ },
  9087. /* 35 */
  9088. /***/ function(module, exports) {
  9089. var DebugContext = (function () {
  9090. function DebugContext(element, componentElement, directive, context, locals, injector) {
  9091. this.element = element;
  9092. this.componentElement = componentElement;
  9093. this.directive = directive;
  9094. this.context = context;
  9095. this.locals = locals;
  9096. this.injector = injector;
  9097. }
  9098. return DebugContext;
  9099. })();
  9100. exports.DebugContext = DebugContext;
  9101. var ChangeDetectorGenConfig = (function () {
  9102. function ChangeDetectorGenConfig(genDebugInfo, logBindingUpdate, useJit) {
  9103. this.genDebugInfo = genDebugInfo;
  9104. this.logBindingUpdate = logBindingUpdate;
  9105. this.useJit = useJit;
  9106. }
  9107. return ChangeDetectorGenConfig;
  9108. })();
  9109. exports.ChangeDetectorGenConfig = ChangeDetectorGenConfig;
  9110. var ChangeDetectorDefinition = (function () {
  9111. function ChangeDetectorDefinition(id, strategy, variableNames, bindingRecords, eventRecords, directiveRecords, genConfig) {
  9112. this.id = id;
  9113. this.strategy = strategy;
  9114. this.variableNames = variableNames;
  9115. this.bindingRecords = bindingRecords;
  9116. this.eventRecords = eventRecords;
  9117. this.directiveRecords = directiveRecords;
  9118. this.genConfig = genConfig;
  9119. }
  9120. return ChangeDetectorDefinition;
  9121. })();
  9122. exports.ChangeDetectorDefinition = ChangeDetectorDefinition;
  9123. /***/ },
  9124. /* 36 */
  9125. /***/ function(module, exports, __webpack_require__) {
  9126. var lang_1 = __webpack_require__(5);
  9127. /**
  9128. * Describes the current state of the change detector.
  9129. */
  9130. (function (ChangeDetectorState) {
  9131. /**
  9132. * `NeverChecked` means that the change detector has not been checked yet, and
  9133. * initialization methods should be called during detection.
  9134. */
  9135. ChangeDetectorState[ChangeDetectorState["NeverChecked"] = 0] = "NeverChecked";
  9136. /**
  9137. * `CheckedBefore` means that the change detector has successfully completed at least
  9138. * one detection previously.
  9139. */
  9140. ChangeDetectorState[ChangeDetectorState["CheckedBefore"] = 1] = "CheckedBefore";
  9141. /**
  9142. * `Errored` means that the change detector encountered an error checking a binding
  9143. * or calling a directive lifecycle method and is now in an inconsistent state. Change
  9144. * detectors in this state will no longer detect changes.
  9145. */
  9146. ChangeDetectorState[ChangeDetectorState["Errored"] = 2] = "Errored";
  9147. })(exports.ChangeDetectorState || (exports.ChangeDetectorState = {}));
  9148. var ChangeDetectorState = exports.ChangeDetectorState;
  9149. /**
  9150. * Describes within the change detector which strategy will be used the next time change
  9151. * detection is triggered.
  9152. */
  9153. (function (ChangeDetectionStrategy) {
  9154. /**
  9155. * `CheckedOnce` means that after calling detectChanges the mode of the change detector
  9156. * will become `Checked`.
  9157. */
  9158. ChangeDetectionStrategy[ChangeDetectionStrategy["CheckOnce"] = 0] = "CheckOnce";
  9159. /**
  9160. * `Checked` means that the change detector should be skipped until its mode changes to
  9161. * `CheckOnce`.
  9162. */
  9163. ChangeDetectionStrategy[ChangeDetectionStrategy["Checked"] = 1] = "Checked";
  9164. /**
  9165. * `CheckAlways` means that after calling detectChanges the mode of the change detector
  9166. * will remain `CheckAlways`.
  9167. */
  9168. ChangeDetectionStrategy[ChangeDetectionStrategy["CheckAlways"] = 2] = "CheckAlways";
  9169. /**
  9170. * `Detached` means that the change detector sub tree is not a part of the main tree and
  9171. * should be skipped.
  9172. */
  9173. ChangeDetectionStrategy[ChangeDetectionStrategy["Detached"] = 3] = "Detached";
  9174. /**
  9175. * `OnPush` means that the change detector's mode will be set to `CheckOnce` during hydration.
  9176. */
  9177. ChangeDetectionStrategy[ChangeDetectionStrategy["OnPush"] = 4] = "OnPush";
  9178. /**
  9179. * `Default` means that the change detector's mode will be set to `CheckAlways` during hydration.
  9180. */
  9181. ChangeDetectionStrategy[ChangeDetectionStrategy["Default"] = 5] = "Default";
  9182. /**
  9183. * This is an experimental feature. Works only in Dart.
  9184. */
  9185. ChangeDetectionStrategy[ChangeDetectionStrategy["OnPushObserve"] = 6] = "OnPushObserve";
  9186. })(exports.ChangeDetectionStrategy || (exports.ChangeDetectionStrategy = {}));
  9187. var ChangeDetectionStrategy = exports.ChangeDetectionStrategy;
  9188. /**
  9189. * List of possible {@link ChangeDetectionStrategy} values.
  9190. */
  9191. exports.CHANGE_DETECTION_STRATEGY_VALUES = [
  9192. ChangeDetectionStrategy.CheckOnce,
  9193. ChangeDetectionStrategy.Checked,
  9194. ChangeDetectionStrategy.CheckAlways,
  9195. ChangeDetectionStrategy.Detached,
  9196. ChangeDetectionStrategy.OnPush,
  9197. ChangeDetectionStrategy.Default,
  9198. ChangeDetectionStrategy.OnPushObserve
  9199. ];
  9200. /**
  9201. * List of possible {@link ChangeDetectorState} values.
  9202. */
  9203. exports.CHANGE_DETECTOR_STATE_VALUES = [
  9204. ChangeDetectorState.NeverChecked,
  9205. ChangeDetectorState.CheckedBefore,
  9206. ChangeDetectorState.Errored
  9207. ];
  9208. function isDefaultChangeDetectionStrategy(changeDetectionStrategy) {
  9209. return lang_1.isBlank(changeDetectionStrategy) ||
  9210. changeDetectionStrategy === ChangeDetectionStrategy.Default;
  9211. }
  9212. exports.isDefaultChangeDetectionStrategy = isDefaultChangeDetectionStrategy;
  9213. /***/ },
  9214. /* 37 */
  9215. /***/ function(module, exports, __webpack_require__) {
  9216. var lang_1 = __webpack_require__(5);
  9217. var exceptions_1 = __webpack_require__(14);
  9218. var collection_1 = __webpack_require__(12);
  9219. var ast_1 = __webpack_require__(30);
  9220. var change_detection_util_1 = __webpack_require__(38);
  9221. var dynamic_change_detector_1 = __webpack_require__(42);
  9222. var directive_record_1 = __webpack_require__(41);
  9223. var event_binding_1 = __webpack_require__(49);
  9224. var coalesce_1 = __webpack_require__(50);
  9225. var proto_record_1 = __webpack_require__(48);
  9226. var DynamicProtoChangeDetector = (function () {
  9227. function DynamicProtoChangeDetector(_definition) {
  9228. this._definition = _definition;
  9229. this._propertyBindingRecords = createPropertyRecords(_definition);
  9230. this._eventBindingRecords = createEventRecords(_definition);
  9231. this._propertyBindingTargets = this._definition.bindingRecords.map(function (b) { return b.target; });
  9232. this._directiveIndices = this._definition.directiveRecords.map(function (d) { return d.directiveIndex; });
  9233. }
  9234. DynamicProtoChangeDetector.prototype.instantiate = function (dispatcher) {
  9235. return new dynamic_change_detector_1.DynamicChangeDetector(this._definition.id, dispatcher, this._propertyBindingRecords.length, this._propertyBindingTargets, this._directiveIndices, this._definition.strategy, this._propertyBindingRecords, this._eventBindingRecords, this._definition.directiveRecords, this._definition.genConfig);
  9236. };
  9237. return DynamicProtoChangeDetector;
  9238. })();
  9239. exports.DynamicProtoChangeDetector = DynamicProtoChangeDetector;
  9240. function createPropertyRecords(definition) {
  9241. var recordBuilder = new ProtoRecordBuilder();
  9242. collection_1.ListWrapper.forEachWithIndex(definition.bindingRecords, function (b, index) { return recordBuilder.add(b, definition.variableNames, index); });
  9243. return coalesce_1.coalesce(recordBuilder.records);
  9244. }
  9245. exports.createPropertyRecords = createPropertyRecords;
  9246. function createEventRecords(definition) {
  9247. // TODO: vsavkin: remove $event when the compiler handles render-side variables properly
  9248. var varNames = collection_1.ListWrapper.concat(['$event'], definition.variableNames);
  9249. return definition.eventRecords.map(function (er) {
  9250. var records = _ConvertAstIntoProtoRecords.create(er, varNames);
  9251. var dirIndex = er.implicitReceiver instanceof directive_record_1.DirectiveIndex ? er.implicitReceiver : null;
  9252. return new event_binding_1.EventBinding(er.target.name, er.target.elementIndex, dirIndex, records);
  9253. });
  9254. }
  9255. exports.createEventRecords = createEventRecords;
  9256. var ProtoRecordBuilder = (function () {
  9257. function ProtoRecordBuilder() {
  9258. this.records = [];
  9259. }
  9260. ProtoRecordBuilder.prototype.add = function (b, variableNames, bindingIndex) {
  9261. var oldLast = collection_1.ListWrapper.last(this.records);
  9262. if (lang_1.isPresent(oldLast) && oldLast.bindingRecord.directiveRecord == b.directiveRecord) {
  9263. oldLast.lastInDirective = false;
  9264. }
  9265. var numberOfRecordsBefore = this.records.length;
  9266. this._appendRecords(b, variableNames, bindingIndex);
  9267. var newLast = collection_1.ListWrapper.last(this.records);
  9268. if (lang_1.isPresent(newLast) && newLast !== oldLast) {
  9269. newLast.lastInBinding = true;
  9270. newLast.lastInDirective = true;
  9271. this._setArgumentToPureFunction(numberOfRecordsBefore);
  9272. }
  9273. };
  9274. /** @internal */
  9275. ProtoRecordBuilder.prototype._setArgumentToPureFunction = function (startIndex) {
  9276. var _this = this;
  9277. for (var i = startIndex; i < this.records.length; ++i) {
  9278. var rec = this.records[i];
  9279. if (rec.isPureFunction()) {
  9280. rec.args.forEach(function (recordIndex) { return _this.records[recordIndex - 1].argumentToPureFunction =
  9281. true; });
  9282. }
  9283. if (rec.mode === proto_record_1.RecordType.Pipe) {
  9284. rec.args.forEach(function (recordIndex) { return _this.records[recordIndex - 1].argumentToPureFunction =
  9285. true; });
  9286. this.records[rec.contextIndex - 1].argumentToPureFunction = true;
  9287. }
  9288. }
  9289. };
  9290. /** @internal */
  9291. ProtoRecordBuilder.prototype._appendRecords = function (b, variableNames, bindingIndex) {
  9292. if (b.isDirectiveLifecycle()) {
  9293. this.records.push(new proto_record_1.ProtoRecord(proto_record_1.RecordType.DirectiveLifecycle, b.lifecycleEvent, null, [], [], -1, null, this.records.length + 1, b, false, false, false, false, null));
  9294. }
  9295. else {
  9296. _ConvertAstIntoProtoRecords.append(this.records, b, variableNames, bindingIndex);
  9297. }
  9298. };
  9299. return ProtoRecordBuilder;
  9300. })();
  9301. exports.ProtoRecordBuilder = ProtoRecordBuilder;
  9302. var _ConvertAstIntoProtoRecords = (function () {
  9303. function _ConvertAstIntoProtoRecords(_records, _bindingRecord, _variableNames, _bindingIndex) {
  9304. this._records = _records;
  9305. this._bindingRecord = _bindingRecord;
  9306. this._variableNames = _variableNames;
  9307. this._bindingIndex = _bindingIndex;
  9308. }
  9309. _ConvertAstIntoProtoRecords.append = function (records, b, variableNames, bindingIndex) {
  9310. var c = new _ConvertAstIntoProtoRecords(records, b, variableNames, bindingIndex);
  9311. b.ast.visit(c);
  9312. };
  9313. _ConvertAstIntoProtoRecords.create = function (b, variableNames) {
  9314. var rec = [];
  9315. _ConvertAstIntoProtoRecords.append(rec, b, variableNames, null);
  9316. rec[rec.length - 1].lastInBinding = true;
  9317. return rec;
  9318. };
  9319. _ConvertAstIntoProtoRecords.prototype.visitImplicitReceiver = function (ast) { return this._bindingRecord.implicitReceiver; };
  9320. _ConvertAstIntoProtoRecords.prototype.visitInterpolation = function (ast) {
  9321. var args = this._visitAll(ast.expressions);
  9322. return this._addRecord(proto_record_1.RecordType.Interpolate, "interpolate", _interpolationFn(ast.strings), args, ast.strings, 0);
  9323. };
  9324. _ConvertAstIntoProtoRecords.prototype.visitLiteralPrimitive = function (ast) {
  9325. return this._addRecord(proto_record_1.RecordType.Const, "literal", ast.value, [], null, 0);
  9326. };
  9327. _ConvertAstIntoProtoRecords.prototype.visitPropertyRead = function (ast) {
  9328. var receiver = ast.receiver.visit(this);
  9329. if (lang_1.isPresent(this._variableNames) && collection_1.ListWrapper.contains(this._variableNames, ast.name) &&
  9330. ast.receiver instanceof ast_1.ImplicitReceiver) {
  9331. return this._addRecord(proto_record_1.RecordType.Local, ast.name, ast.name, [], null, receiver);
  9332. }
  9333. else {
  9334. return this._addRecord(proto_record_1.RecordType.PropertyRead, ast.name, ast.getter, [], null, receiver);
  9335. }
  9336. };
  9337. _ConvertAstIntoProtoRecords.prototype.visitPropertyWrite = function (ast) {
  9338. if (lang_1.isPresent(this._variableNames) && collection_1.ListWrapper.contains(this._variableNames, ast.name) &&
  9339. ast.receiver instanceof ast_1.ImplicitReceiver) {
  9340. throw new exceptions_1.BaseException("Cannot reassign a variable binding " + ast.name);
  9341. }
  9342. else {
  9343. var receiver = ast.receiver.visit(this);
  9344. var value = ast.value.visit(this);
  9345. return this._addRecord(proto_record_1.RecordType.PropertyWrite, ast.name, ast.setter, [value], null, receiver);
  9346. }
  9347. };
  9348. _ConvertAstIntoProtoRecords.prototype.visitKeyedWrite = function (ast) {
  9349. var obj = ast.obj.visit(this);
  9350. var key = ast.key.visit(this);
  9351. var value = ast.value.visit(this);
  9352. return this._addRecord(proto_record_1.RecordType.KeyedWrite, null, null, [key, value], null, obj);
  9353. };
  9354. _ConvertAstIntoProtoRecords.prototype.visitSafePropertyRead = function (ast) {
  9355. var receiver = ast.receiver.visit(this);
  9356. return this._addRecord(proto_record_1.RecordType.SafeProperty, ast.name, ast.getter, [], null, receiver);
  9357. };
  9358. _ConvertAstIntoProtoRecords.prototype.visitMethodCall = function (ast) {
  9359. var receiver = ast.receiver.visit(this);
  9360. var args = this._visitAll(ast.args);
  9361. if (lang_1.isPresent(this._variableNames) && collection_1.ListWrapper.contains(this._variableNames, ast.name)) {
  9362. var target = this._addRecord(proto_record_1.RecordType.Local, ast.name, ast.name, [], null, receiver);
  9363. return this._addRecord(proto_record_1.RecordType.InvokeClosure, "closure", null, args, null, target);
  9364. }
  9365. else {
  9366. return this._addRecord(proto_record_1.RecordType.InvokeMethod, ast.name, ast.fn, args, null, receiver);
  9367. }
  9368. };
  9369. _ConvertAstIntoProtoRecords.prototype.visitSafeMethodCall = function (ast) {
  9370. var receiver = ast.receiver.visit(this);
  9371. var args = this._visitAll(ast.args);
  9372. return this._addRecord(proto_record_1.RecordType.SafeMethodInvoke, ast.name, ast.fn, args, null, receiver);
  9373. };
  9374. _ConvertAstIntoProtoRecords.prototype.visitFunctionCall = function (ast) {
  9375. var target = ast.target.visit(this);
  9376. var args = this._visitAll(ast.args);
  9377. return this._addRecord(proto_record_1.RecordType.InvokeClosure, "closure", null, args, null, target);
  9378. };
  9379. _ConvertAstIntoProtoRecords.prototype.visitLiteralArray = function (ast) {
  9380. var primitiveName = "arrayFn" + ast.expressions.length;
  9381. return this._addRecord(proto_record_1.RecordType.CollectionLiteral, primitiveName, _arrayFn(ast.expressions.length), this._visitAll(ast.expressions), null, 0);
  9382. };
  9383. _ConvertAstIntoProtoRecords.prototype.visitLiteralMap = function (ast) {
  9384. return this._addRecord(proto_record_1.RecordType.CollectionLiteral, _mapPrimitiveName(ast.keys), change_detection_util_1.ChangeDetectionUtil.mapFn(ast.keys), this._visitAll(ast.values), null, 0);
  9385. };
  9386. _ConvertAstIntoProtoRecords.prototype.visitBinary = function (ast) {
  9387. var left = ast.left.visit(this);
  9388. switch (ast.operation) {
  9389. case '&&':
  9390. var branchEnd = [null];
  9391. this._addRecord(proto_record_1.RecordType.SkipRecordsIfNot, "SkipRecordsIfNot", null, [], branchEnd, left);
  9392. var right = ast.right.visit(this);
  9393. branchEnd[0] = right;
  9394. return this._addRecord(proto_record_1.RecordType.PrimitiveOp, "cond", change_detection_util_1.ChangeDetectionUtil.cond, [left, right, left], null, 0);
  9395. case '||':
  9396. var branchEnd = [null];
  9397. this._addRecord(proto_record_1.RecordType.SkipRecordsIf, "SkipRecordsIf", null, [], branchEnd, left);
  9398. var right = ast.right.visit(this);
  9399. branchEnd[0] = right;
  9400. return this._addRecord(proto_record_1.RecordType.PrimitiveOp, "cond", change_detection_util_1.ChangeDetectionUtil.cond, [left, left, right], null, 0);
  9401. default:
  9402. var right = ast.right.visit(this);
  9403. return this._addRecord(proto_record_1.RecordType.PrimitiveOp, _operationToPrimitiveName(ast.operation), _operationToFunction(ast.operation), [left, right], null, 0);
  9404. }
  9405. };
  9406. _ConvertAstIntoProtoRecords.prototype.visitPrefixNot = function (ast) {
  9407. var exp = ast.expression.visit(this);
  9408. return this._addRecord(proto_record_1.RecordType.PrimitiveOp, "operation_negate", change_detection_util_1.ChangeDetectionUtil.operation_negate, [exp], null, 0);
  9409. };
  9410. _ConvertAstIntoProtoRecords.prototype.visitConditional = function (ast) {
  9411. var condition = ast.condition.visit(this);
  9412. var startOfFalseBranch = [null];
  9413. var endOfFalseBranch = [null];
  9414. this._addRecord(proto_record_1.RecordType.SkipRecordsIfNot, "SkipRecordsIfNot", null, [], startOfFalseBranch, condition);
  9415. var whenTrue = ast.trueExp.visit(this);
  9416. var skip = this._addRecord(proto_record_1.RecordType.SkipRecords, "SkipRecords", null, [], endOfFalseBranch, 0);
  9417. var whenFalse = ast.falseExp.visit(this);
  9418. startOfFalseBranch[0] = skip;
  9419. endOfFalseBranch[0] = whenFalse;
  9420. return this._addRecord(proto_record_1.RecordType.PrimitiveOp, "cond", change_detection_util_1.ChangeDetectionUtil.cond, [condition, whenTrue, whenFalse], null, 0);
  9421. };
  9422. _ConvertAstIntoProtoRecords.prototype.visitPipe = function (ast) {
  9423. var value = ast.exp.visit(this);
  9424. var args = this._visitAll(ast.args);
  9425. return this._addRecord(proto_record_1.RecordType.Pipe, ast.name, ast.name, args, null, value);
  9426. };
  9427. _ConvertAstIntoProtoRecords.prototype.visitKeyedRead = function (ast) {
  9428. var obj = ast.obj.visit(this);
  9429. var key = ast.key.visit(this);
  9430. return this._addRecord(proto_record_1.RecordType.KeyedRead, "keyedAccess", change_detection_util_1.ChangeDetectionUtil.keyedAccess, [key], null, obj);
  9431. };
  9432. _ConvertAstIntoProtoRecords.prototype.visitChain = function (ast) {
  9433. var _this = this;
  9434. var args = ast.expressions.map(function (e) { return e.visit(_this); });
  9435. return this._addRecord(proto_record_1.RecordType.Chain, "chain", null, args, null, 0);
  9436. };
  9437. _ConvertAstIntoProtoRecords.prototype.visitQuote = function (ast) {
  9438. throw new exceptions_1.BaseException(("Caught uninterpreted expression at " + ast.location + ": " + ast.uninterpretedExpression + ". ") +
  9439. ("Expression prefix " + ast.prefix + " did not match a template transformer to interpret the expression."));
  9440. };
  9441. _ConvertAstIntoProtoRecords.prototype._visitAll = function (asts) {
  9442. var res = collection_1.ListWrapper.createFixedSize(asts.length);
  9443. for (var i = 0; i < asts.length; ++i) {
  9444. res[i] = asts[i].visit(this);
  9445. }
  9446. return res;
  9447. };
  9448. /**
  9449. * Adds a `ProtoRecord` and returns its selfIndex.
  9450. */
  9451. _ConvertAstIntoProtoRecords.prototype._addRecord = function (type, name, funcOrValue, args, fixedArgs, context) {
  9452. var selfIndex = this._records.length + 1;
  9453. if (context instanceof directive_record_1.DirectiveIndex) {
  9454. this._records.push(new proto_record_1.ProtoRecord(type, name, funcOrValue, args, fixedArgs, -1, context, selfIndex, this._bindingRecord, false, false, false, false, this._bindingIndex));
  9455. }
  9456. else {
  9457. this._records.push(new proto_record_1.ProtoRecord(type, name, funcOrValue, args, fixedArgs, context, null, selfIndex, this._bindingRecord, false, false, false, false, this._bindingIndex));
  9458. }
  9459. return selfIndex;
  9460. };
  9461. return _ConvertAstIntoProtoRecords;
  9462. })();
  9463. function _arrayFn(length) {
  9464. switch (length) {
  9465. case 0:
  9466. return change_detection_util_1.ChangeDetectionUtil.arrayFn0;
  9467. case 1:
  9468. return change_detection_util_1.ChangeDetectionUtil.arrayFn1;
  9469. case 2:
  9470. return change_detection_util_1.ChangeDetectionUtil.arrayFn2;
  9471. case 3:
  9472. return change_detection_util_1.ChangeDetectionUtil.arrayFn3;
  9473. case 4:
  9474. return change_detection_util_1.ChangeDetectionUtil.arrayFn4;
  9475. case 5:
  9476. return change_detection_util_1.ChangeDetectionUtil.arrayFn5;
  9477. case 6:
  9478. return change_detection_util_1.ChangeDetectionUtil.arrayFn6;
  9479. case 7:
  9480. return change_detection_util_1.ChangeDetectionUtil.arrayFn7;
  9481. case 8:
  9482. return change_detection_util_1.ChangeDetectionUtil.arrayFn8;
  9483. case 9:
  9484. return change_detection_util_1.ChangeDetectionUtil.arrayFn9;
  9485. default:
  9486. throw new exceptions_1.BaseException("Does not support literal maps with more than 9 elements");
  9487. }
  9488. }
  9489. function _mapPrimitiveName(keys) {
  9490. var stringifiedKeys = keys.map(function (k) { return lang_1.isString(k) ? "\"" + k + "\"" : "" + k; }).join(', ');
  9491. return "mapFn([" + stringifiedKeys + "])";
  9492. }
  9493. function _operationToPrimitiveName(operation) {
  9494. switch (operation) {
  9495. case '+':
  9496. return "operation_add";
  9497. case '-':
  9498. return "operation_subtract";
  9499. case '*':
  9500. return "operation_multiply";
  9501. case '/':
  9502. return "operation_divide";
  9503. case '%':
  9504. return "operation_remainder";
  9505. case '==':
  9506. return "operation_equals";
  9507. case '!=':
  9508. return "operation_not_equals";
  9509. case '===':
  9510. return "operation_identical";
  9511. case '!==':
  9512. return "operation_not_identical";
  9513. case '<':
  9514. return "operation_less_then";
  9515. case '>':
  9516. return "operation_greater_then";
  9517. case '<=':
  9518. return "operation_less_or_equals_then";
  9519. case '>=':
  9520. return "operation_greater_or_equals_then";
  9521. default:
  9522. throw new exceptions_1.BaseException("Unsupported operation " + operation);
  9523. }
  9524. }
  9525. function _operationToFunction(operation) {
  9526. switch (operation) {
  9527. case '+':
  9528. return change_detection_util_1.ChangeDetectionUtil.operation_add;
  9529. case '-':
  9530. return change_detection_util_1.ChangeDetectionUtil.operation_subtract;
  9531. case '*':
  9532. return change_detection_util_1.ChangeDetectionUtil.operation_multiply;
  9533. case '/':
  9534. return change_detection_util_1.ChangeDetectionUtil.operation_divide;
  9535. case '%':
  9536. return change_detection_util_1.ChangeDetectionUtil.operation_remainder;
  9537. case '==':
  9538. return change_detection_util_1.ChangeDetectionUtil.operation_equals;
  9539. case '!=':
  9540. return change_detection_util_1.ChangeDetectionUtil.operation_not_equals;
  9541. case '===':
  9542. return change_detection_util_1.ChangeDetectionUtil.operation_identical;
  9543. case '!==':
  9544. return change_detection_util_1.ChangeDetectionUtil.operation_not_identical;
  9545. case '<':
  9546. return change_detection_util_1.ChangeDetectionUtil.operation_less_then;
  9547. case '>':
  9548. return change_detection_util_1.ChangeDetectionUtil.operation_greater_then;
  9549. case '<=':
  9550. return change_detection_util_1.ChangeDetectionUtil.operation_less_or_equals_then;
  9551. case '>=':
  9552. return change_detection_util_1.ChangeDetectionUtil.operation_greater_or_equals_then;
  9553. default:
  9554. throw new exceptions_1.BaseException("Unsupported operation " + operation);
  9555. }
  9556. }
  9557. function s(v) {
  9558. return lang_1.isPresent(v) ? "" + v : '';
  9559. }
  9560. function _interpolationFn(strings) {
  9561. var length = strings.length;
  9562. var c0 = length > 0 ? strings[0] : null;
  9563. var c1 = length > 1 ? strings[1] : null;
  9564. var c2 = length > 2 ? strings[2] : null;
  9565. var c3 = length > 3 ? strings[3] : null;
  9566. var c4 = length > 4 ? strings[4] : null;
  9567. var c5 = length > 5 ? strings[5] : null;
  9568. var c6 = length > 6 ? strings[6] : null;
  9569. var c7 = length > 7 ? strings[7] : null;
  9570. var c8 = length > 8 ? strings[8] : null;
  9571. var c9 = length > 9 ? strings[9] : null;
  9572. switch (length - 1) {
  9573. case 1:
  9574. return function (a1) { return c0 + s(a1) + c1; };
  9575. case 2:
  9576. return function (a1, a2) { return c0 + s(a1) + c1 + s(a2) + c2; };
  9577. case 3:
  9578. return function (a1, a2, a3) { return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3; };
  9579. case 4:
  9580. return function (a1, a2, a3, a4) { return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3 + s(a4) + c4; };
  9581. case 5:
  9582. return function (a1, a2, a3, a4, a5) {
  9583. return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3 + s(a4) + c4 + s(a5) + c5;
  9584. };
  9585. case 6:
  9586. return function (a1, a2, a3, a4, a5, a6) {
  9587. return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3 + s(a4) + c4 + s(a5) + c5 + s(a6) + c6;
  9588. };
  9589. case 7:
  9590. return function (a1, a2, a3, a4, a5, a6, a7) { return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3 + s(a4) +
  9591. c4 + s(a5) + c5 + s(a6) + c6 + s(a7) + c7; };
  9592. case 8:
  9593. return function (a1, a2, a3, a4, a5, a6, a7, a8) { return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3 + s(a4) +
  9594. c4 + s(a5) + c5 + s(a6) + c6 + s(a7) + c7 + s(a8) +
  9595. c8; };
  9596. case 9:
  9597. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9) { return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3 +
  9598. s(a4) + c4 + s(a5) + c5 + s(a6) + c6 + s(a7) +
  9599. c7 + s(a8) + c8 + s(a9) + c9; };
  9600. default:
  9601. throw new exceptions_1.BaseException("Does not support more than 9 expressions");
  9602. }
  9603. }
  9604. /***/ },
  9605. /* 38 */
  9606. /***/ function(module, exports, __webpack_require__) {
  9607. var lang_1 = __webpack_require__(5);
  9608. var exceptions_1 = __webpack_require__(14);
  9609. var collection_1 = __webpack_require__(12);
  9610. var constants_1 = __webpack_require__(36);
  9611. var pipe_lifecycle_reflector_1 = __webpack_require__(39);
  9612. var binding_record_1 = __webpack_require__(40);
  9613. var directive_record_1 = __webpack_require__(41);
  9614. /**
  9615. * Indicates that the result of a {@link PipeMetadata} transformation has changed even though the
  9616. * reference
  9617. * has not changed.
  9618. *
  9619. * The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.
  9620. *
  9621. * Example:
  9622. *
  9623. * ```
  9624. * if (this._latestValue === this._latestReturnedValue) {
  9625. * return this._latestReturnedValue;
  9626. * } else {
  9627. * this._latestReturnedValue = this._latestValue;
  9628. * return WrappedValue.wrap(this._latestValue); // this will force update
  9629. * }
  9630. * ```
  9631. */
  9632. var WrappedValue = (function () {
  9633. function WrappedValue(wrapped) {
  9634. this.wrapped = wrapped;
  9635. }
  9636. WrappedValue.wrap = function (value) {
  9637. var w = _wrappedValues[_wrappedIndex++ % 5];
  9638. w.wrapped = value;
  9639. return w;
  9640. };
  9641. return WrappedValue;
  9642. })();
  9643. exports.WrappedValue = WrappedValue;
  9644. var _wrappedValues = [
  9645. new WrappedValue(null),
  9646. new WrappedValue(null),
  9647. new WrappedValue(null),
  9648. new WrappedValue(null),
  9649. new WrappedValue(null)
  9650. ];
  9651. var _wrappedIndex = 0;
  9652. /**
  9653. * Represents a basic change from a previous to a new value.
  9654. */
  9655. var SimpleChange = (function () {
  9656. function SimpleChange(previousValue, currentValue) {
  9657. this.previousValue = previousValue;
  9658. this.currentValue = currentValue;
  9659. }
  9660. /**
  9661. * Check whether the new value is the first value assigned.
  9662. */
  9663. SimpleChange.prototype.isFirstChange = function () { return this.previousValue === ChangeDetectionUtil.uninitialized; };
  9664. return SimpleChange;
  9665. })();
  9666. exports.SimpleChange = SimpleChange;
  9667. var _simpleChangesIndex = 0;
  9668. var _simpleChanges = [
  9669. new SimpleChange(null, null),
  9670. new SimpleChange(null, null),
  9671. new SimpleChange(null, null),
  9672. new SimpleChange(null, null),
  9673. new SimpleChange(null, null),
  9674. new SimpleChange(null, null),
  9675. new SimpleChange(null, null),
  9676. new SimpleChange(null, null),
  9677. new SimpleChange(null, null),
  9678. new SimpleChange(null, null),
  9679. new SimpleChange(null, null),
  9680. new SimpleChange(null, null),
  9681. new SimpleChange(null, null),
  9682. new SimpleChange(null, null),
  9683. new SimpleChange(null, null),
  9684. new SimpleChange(null, null),
  9685. new SimpleChange(null, null),
  9686. new SimpleChange(null, null),
  9687. new SimpleChange(null, null),
  9688. new SimpleChange(null, null)
  9689. ];
  9690. function _simpleChange(previousValue, currentValue) {
  9691. var index = _simpleChangesIndex++ % 20;
  9692. var s = _simpleChanges[index];
  9693. s.previousValue = previousValue;
  9694. s.currentValue = currentValue;
  9695. return s;
  9696. }
  9697. /* tslint:disable:requireParameterType */
  9698. var ChangeDetectionUtil = (function () {
  9699. function ChangeDetectionUtil() {
  9700. }
  9701. ChangeDetectionUtil.arrayFn0 = function () { return []; };
  9702. ChangeDetectionUtil.arrayFn1 = function (a1) { return [a1]; };
  9703. ChangeDetectionUtil.arrayFn2 = function (a1, a2) { return [a1, a2]; };
  9704. ChangeDetectionUtil.arrayFn3 = function (a1, a2, a3) { return [a1, a2, a3]; };
  9705. ChangeDetectionUtil.arrayFn4 = function (a1, a2, a3, a4) { return [a1, a2, a3, a4]; };
  9706. ChangeDetectionUtil.arrayFn5 = function (a1, a2, a3, a4, a5) { return [a1, a2, a3, a4, a5]; };
  9707. ChangeDetectionUtil.arrayFn6 = function (a1, a2, a3, a4, a5, a6) { return [a1, a2, a3, a4, a5, a6]; };
  9708. ChangeDetectionUtil.arrayFn7 = function (a1, a2, a3, a4, a5, a6, a7) { return [a1, a2, a3, a4, a5, a6, a7]; };
  9709. ChangeDetectionUtil.arrayFn8 = function (a1, a2, a3, a4, a5, a6, a7, a8) {
  9710. return [a1, a2, a3, a4, a5, a6, a7, a8];
  9711. };
  9712. ChangeDetectionUtil.arrayFn9 = function (a1, a2, a3, a4, a5, a6, a7, a8, a9) {
  9713. return [a1, a2, a3, a4, a5, a6, a7, a8, a9];
  9714. };
  9715. ChangeDetectionUtil.operation_negate = function (value) { return !value; };
  9716. ChangeDetectionUtil.operation_add = function (left, right) { return left + right; };
  9717. ChangeDetectionUtil.operation_subtract = function (left, right) { return left - right; };
  9718. ChangeDetectionUtil.operation_multiply = function (left, right) { return left * right; };
  9719. ChangeDetectionUtil.operation_divide = function (left, right) { return left / right; };
  9720. ChangeDetectionUtil.operation_remainder = function (left, right) { return left % right; };
  9721. ChangeDetectionUtil.operation_equals = function (left, right) { return left == right; };
  9722. ChangeDetectionUtil.operation_not_equals = function (left, right) { return left != right; };
  9723. ChangeDetectionUtil.operation_identical = function (left, right) { return left === right; };
  9724. ChangeDetectionUtil.operation_not_identical = function (left, right) { return left !== right; };
  9725. ChangeDetectionUtil.operation_less_then = function (left, right) { return left < right; };
  9726. ChangeDetectionUtil.operation_greater_then = function (left, right) { return left > right; };
  9727. ChangeDetectionUtil.operation_less_or_equals_then = function (left, right) { return left <= right; };
  9728. ChangeDetectionUtil.operation_greater_or_equals_then = function (left, right) { return left >= right; };
  9729. ChangeDetectionUtil.cond = function (cond, trueVal, falseVal) { return cond ? trueVal : falseVal; };
  9730. ChangeDetectionUtil.mapFn = function (keys) {
  9731. function buildMap(values) {
  9732. var res = collection_1.StringMapWrapper.create();
  9733. for (var i = 0; i < keys.length; ++i) {
  9734. collection_1.StringMapWrapper.set(res, keys[i], values[i]);
  9735. }
  9736. return res;
  9737. }
  9738. switch (keys.length) {
  9739. case 0:
  9740. return function () { return []; };
  9741. case 1:
  9742. return function (a1) { return buildMap([a1]); };
  9743. case 2:
  9744. return function (a1, a2) { return buildMap([a1, a2]); };
  9745. case 3:
  9746. return function (a1, a2, a3) { return buildMap([a1, a2, a3]); };
  9747. case 4:
  9748. return function (a1, a2, a3, a4) { return buildMap([a1, a2, a3, a4]); };
  9749. case 5:
  9750. return function (a1, a2, a3, a4, a5) { return buildMap([a1, a2, a3, a4, a5]); };
  9751. case 6:
  9752. return function (a1, a2, a3, a4, a5, a6) { return buildMap([a1, a2, a3, a4, a5, a6]); };
  9753. case 7:
  9754. return function (a1, a2, a3, a4, a5, a6, a7) { return buildMap([a1, a2, a3, a4, a5, a6, a7]); };
  9755. case 8:
  9756. return function (a1, a2, a3, a4, a5, a6, a7, a8) { return buildMap([a1, a2, a3, a4, a5, a6, a7, a8]); };
  9757. case 9:
  9758. return function (a1, a2, a3, a4, a5, a6, a7, a8, a9) {
  9759. return buildMap([a1, a2, a3, a4, a5, a6, a7, a8, a9]);
  9760. };
  9761. default:
  9762. throw new exceptions_1.BaseException("Does not support literal maps with more than 9 elements");
  9763. }
  9764. };
  9765. ChangeDetectionUtil.keyedAccess = function (obj, args) { return obj[args[0]]; };
  9766. ChangeDetectionUtil.unwrapValue = function (value) {
  9767. if (value instanceof WrappedValue) {
  9768. return value.wrapped;
  9769. }
  9770. else {
  9771. return value;
  9772. }
  9773. };
  9774. ChangeDetectionUtil.changeDetectionMode = function (strategy) {
  9775. return constants_1.isDefaultChangeDetectionStrategy(strategy) ? constants_1.ChangeDetectionStrategy.CheckAlways :
  9776. constants_1.ChangeDetectionStrategy.CheckOnce;
  9777. };
  9778. ChangeDetectionUtil.simpleChange = function (previousValue, currentValue) {
  9779. return _simpleChange(previousValue, currentValue);
  9780. };
  9781. ChangeDetectionUtil.isValueBlank = function (value) { return lang_1.isBlank(value); };
  9782. ChangeDetectionUtil.s = function (value) { return lang_1.isPresent(value) ? "" + value : ''; };
  9783. ChangeDetectionUtil.protoByIndex = function (protos, selfIndex) {
  9784. return selfIndex < 1 ?
  9785. null :
  9786. protos[selfIndex - 1]; // self index is shifted by one because of context
  9787. };
  9788. ChangeDetectionUtil.callPipeOnDestroy = function (selectedPipe) {
  9789. if (pipe_lifecycle_reflector_1.implementsOnDestroy(selectedPipe.pipe)) {
  9790. selectedPipe.pipe.ngOnDestroy();
  9791. }
  9792. };
  9793. ChangeDetectionUtil.bindingTarget = function (mode, elementIndex, name, unit, debug) {
  9794. return new binding_record_1.BindingTarget(mode, elementIndex, name, unit, debug);
  9795. };
  9796. ChangeDetectionUtil.directiveIndex = function (elementIndex, directiveIndex) {
  9797. return new directive_record_1.DirectiveIndex(elementIndex, directiveIndex);
  9798. };
  9799. ChangeDetectionUtil.looseNotIdentical = function (a, b) { return !lang_1.looseIdentical(a, b); };
  9800. ChangeDetectionUtil.uninitialized = lang_1.CONST_EXPR(new Object());
  9801. return ChangeDetectionUtil;
  9802. })();
  9803. exports.ChangeDetectionUtil = ChangeDetectionUtil;
  9804. /***/ },
  9805. /* 39 */
  9806. /***/ function(module, exports) {
  9807. function implementsOnDestroy(pipe) {
  9808. return pipe.constructor.prototype.ngOnDestroy;
  9809. }
  9810. exports.implementsOnDestroy = implementsOnDestroy;
  9811. /***/ },
  9812. /* 40 */
  9813. /***/ function(module, exports, __webpack_require__) {
  9814. var lang_1 = __webpack_require__(5);
  9815. var DIRECTIVE_LIFECYCLE = "directiveLifecycle";
  9816. var BINDING = "native";
  9817. var DIRECTIVE = "directive";
  9818. var ELEMENT_PROPERTY = "elementProperty";
  9819. var ELEMENT_ATTRIBUTE = "elementAttribute";
  9820. var ELEMENT_CLASS = "elementClass";
  9821. var ELEMENT_STYLE = "elementStyle";
  9822. var TEXT_NODE = "textNode";
  9823. var EVENT = "event";
  9824. var HOST_EVENT = "hostEvent";
  9825. var BindingTarget = (function () {
  9826. function BindingTarget(mode, elementIndex, name, unit, debug) {
  9827. this.mode = mode;
  9828. this.elementIndex = elementIndex;
  9829. this.name = name;
  9830. this.unit = unit;
  9831. this.debug = debug;
  9832. }
  9833. BindingTarget.prototype.isDirective = function () { return this.mode === DIRECTIVE; };
  9834. BindingTarget.prototype.isElementProperty = function () { return this.mode === ELEMENT_PROPERTY; };
  9835. BindingTarget.prototype.isElementAttribute = function () { return this.mode === ELEMENT_ATTRIBUTE; };
  9836. BindingTarget.prototype.isElementClass = function () { return this.mode === ELEMENT_CLASS; };
  9837. BindingTarget.prototype.isElementStyle = function () { return this.mode === ELEMENT_STYLE; };
  9838. BindingTarget.prototype.isTextNode = function () { return this.mode === TEXT_NODE; };
  9839. return BindingTarget;
  9840. })();
  9841. exports.BindingTarget = BindingTarget;
  9842. var BindingRecord = (function () {
  9843. function BindingRecord(mode, target, implicitReceiver, ast, setter, lifecycleEvent, directiveRecord) {
  9844. this.mode = mode;
  9845. this.target = target;
  9846. this.implicitReceiver = implicitReceiver;
  9847. this.ast = ast;
  9848. this.setter = setter;
  9849. this.lifecycleEvent = lifecycleEvent;
  9850. this.directiveRecord = directiveRecord;
  9851. }
  9852. BindingRecord.prototype.isDirectiveLifecycle = function () { return this.mode === DIRECTIVE_LIFECYCLE; };
  9853. BindingRecord.prototype.callOnChanges = function () {
  9854. return lang_1.isPresent(this.directiveRecord) && this.directiveRecord.callOnChanges;
  9855. };
  9856. BindingRecord.prototype.isDefaultChangeDetection = function () {
  9857. return lang_1.isBlank(this.directiveRecord) || this.directiveRecord.isDefaultChangeDetection();
  9858. };
  9859. BindingRecord.createDirectiveDoCheck = function (directiveRecord) {
  9860. return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "DoCheck", directiveRecord);
  9861. };
  9862. BindingRecord.createDirectiveOnInit = function (directiveRecord) {
  9863. return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "OnInit", directiveRecord);
  9864. };
  9865. BindingRecord.createDirectiveOnChanges = function (directiveRecord) {
  9866. return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "OnChanges", directiveRecord);
  9867. };
  9868. BindingRecord.createForDirective = function (ast, propertyName, setter, directiveRecord) {
  9869. var elementIndex = directiveRecord.directiveIndex.elementIndex;
  9870. var t = new BindingTarget(DIRECTIVE, elementIndex, propertyName, null, ast.toString());
  9871. return new BindingRecord(DIRECTIVE, t, 0, ast, setter, null, directiveRecord);
  9872. };
  9873. BindingRecord.createForElementProperty = function (ast, elementIndex, propertyName) {
  9874. var t = new BindingTarget(ELEMENT_PROPERTY, elementIndex, propertyName, null, ast.toString());
  9875. return new BindingRecord(BINDING, t, 0, ast, null, null, null);
  9876. };
  9877. BindingRecord.createForElementAttribute = function (ast, elementIndex, attributeName) {
  9878. var t = new BindingTarget(ELEMENT_ATTRIBUTE, elementIndex, attributeName, null, ast.toString());
  9879. return new BindingRecord(BINDING, t, 0, ast, null, null, null);
  9880. };
  9881. BindingRecord.createForElementClass = function (ast, elementIndex, className) {
  9882. var t = new BindingTarget(ELEMENT_CLASS, elementIndex, className, null, ast.toString());
  9883. return new BindingRecord(BINDING, t, 0, ast, null, null, null);
  9884. };
  9885. BindingRecord.createForElementStyle = function (ast, elementIndex, styleName, unit) {
  9886. var t = new BindingTarget(ELEMENT_STYLE, elementIndex, styleName, unit, ast.toString());
  9887. return new BindingRecord(BINDING, t, 0, ast, null, null, null);
  9888. };
  9889. BindingRecord.createForHostProperty = function (directiveIndex, ast, propertyName) {
  9890. var t = new BindingTarget(ELEMENT_PROPERTY, directiveIndex.elementIndex, propertyName, null, ast.toString());
  9891. return new BindingRecord(BINDING, t, directiveIndex, ast, null, null, null);
  9892. };
  9893. BindingRecord.createForHostAttribute = function (directiveIndex, ast, attributeName) {
  9894. var t = new BindingTarget(ELEMENT_ATTRIBUTE, directiveIndex.elementIndex, attributeName, null, ast.toString());
  9895. return new BindingRecord(BINDING, t, directiveIndex, ast, null, null, null);
  9896. };
  9897. BindingRecord.createForHostClass = function (directiveIndex, ast, className) {
  9898. var t = new BindingTarget(ELEMENT_CLASS, directiveIndex.elementIndex, className, null, ast.toString());
  9899. return new BindingRecord(BINDING, t, directiveIndex, ast, null, null, null);
  9900. };
  9901. BindingRecord.createForHostStyle = function (directiveIndex, ast, styleName, unit) {
  9902. var t = new BindingTarget(ELEMENT_STYLE, directiveIndex.elementIndex, styleName, unit, ast.toString());
  9903. return new BindingRecord(BINDING, t, directiveIndex, ast, null, null, null);
  9904. };
  9905. BindingRecord.createForTextNode = function (ast, elementIndex) {
  9906. var t = new BindingTarget(TEXT_NODE, elementIndex, null, null, ast.toString());
  9907. return new BindingRecord(BINDING, t, 0, ast, null, null, null);
  9908. };
  9909. BindingRecord.createForEvent = function (ast, eventName, elementIndex) {
  9910. var t = new BindingTarget(EVENT, elementIndex, eventName, null, ast.toString());
  9911. return new BindingRecord(EVENT, t, 0, ast, null, null, null);
  9912. };
  9913. BindingRecord.createForHostEvent = function (ast, eventName, directiveRecord) {
  9914. var directiveIndex = directiveRecord.directiveIndex;
  9915. var t = new BindingTarget(HOST_EVENT, directiveIndex.elementIndex, eventName, null, ast.toString());
  9916. return new BindingRecord(HOST_EVENT, t, directiveIndex, ast, null, null, directiveRecord);
  9917. };
  9918. return BindingRecord;
  9919. })();
  9920. exports.BindingRecord = BindingRecord;
  9921. /***/ },
  9922. /* 41 */
  9923. /***/ function(module, exports, __webpack_require__) {
  9924. var lang_1 = __webpack_require__(5);
  9925. var constants_1 = __webpack_require__(36);
  9926. var DirectiveIndex = (function () {
  9927. function DirectiveIndex(elementIndex, directiveIndex) {
  9928. this.elementIndex = elementIndex;
  9929. this.directiveIndex = directiveIndex;
  9930. }
  9931. Object.defineProperty(DirectiveIndex.prototype, "name", {
  9932. get: function () { return this.elementIndex + "_" + this.directiveIndex; },
  9933. enumerable: true,
  9934. configurable: true
  9935. });
  9936. return DirectiveIndex;
  9937. })();
  9938. exports.DirectiveIndex = DirectiveIndex;
  9939. var DirectiveRecord = (function () {
  9940. function DirectiveRecord(_a) {
  9941. var _b = _a === void 0 ? {} : _a, directiveIndex = _b.directiveIndex, callAfterContentInit = _b.callAfterContentInit, callAfterContentChecked = _b.callAfterContentChecked, callAfterViewInit = _b.callAfterViewInit, callAfterViewChecked = _b.callAfterViewChecked, callOnChanges = _b.callOnChanges, callDoCheck = _b.callDoCheck, callOnInit = _b.callOnInit, changeDetection = _b.changeDetection;
  9942. this.directiveIndex = directiveIndex;
  9943. this.callAfterContentInit = lang_1.normalizeBool(callAfterContentInit);
  9944. this.callAfterContentChecked = lang_1.normalizeBool(callAfterContentChecked);
  9945. this.callOnChanges = lang_1.normalizeBool(callOnChanges);
  9946. this.callAfterViewInit = lang_1.normalizeBool(callAfterViewInit);
  9947. this.callAfterViewChecked = lang_1.normalizeBool(callAfterViewChecked);
  9948. this.callDoCheck = lang_1.normalizeBool(callDoCheck);
  9949. this.callOnInit = lang_1.normalizeBool(callOnInit);
  9950. this.changeDetection = changeDetection;
  9951. }
  9952. DirectiveRecord.prototype.isDefaultChangeDetection = function () {
  9953. return constants_1.isDefaultChangeDetectionStrategy(this.changeDetection);
  9954. };
  9955. return DirectiveRecord;
  9956. })();
  9957. exports.DirectiveRecord = DirectiveRecord;
  9958. /***/ },
  9959. /* 42 */
  9960. /***/ function(module, exports, __webpack_require__) {
  9961. var __extends = (this && this.__extends) || function (d, b) {
  9962. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  9963. function __() { this.constructor = d; }
  9964. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9965. };
  9966. var lang_1 = __webpack_require__(5);
  9967. var exceptions_1 = __webpack_require__(14);
  9968. var collection_1 = __webpack_require__(12);
  9969. var abstract_change_detector_1 = __webpack_require__(43);
  9970. var change_detection_util_1 = __webpack_require__(38);
  9971. var constants_1 = __webpack_require__(36);
  9972. var proto_record_1 = __webpack_require__(48);
  9973. var DynamicChangeDetector = (function (_super) {
  9974. __extends(DynamicChangeDetector, _super);
  9975. function DynamicChangeDetector(id, dispatcher, numberOfPropertyProtoRecords, propertyBindingTargets, directiveIndices, strategy, _records, _eventBindings, _directiveRecords, _genConfig) {
  9976. _super.call(this, id, dispatcher, numberOfPropertyProtoRecords, propertyBindingTargets, directiveIndices, strategy);
  9977. this._records = _records;
  9978. this._eventBindings = _eventBindings;
  9979. this._directiveRecords = _directiveRecords;
  9980. this._genConfig = _genConfig;
  9981. this.directives = null;
  9982. var len = _records.length + 1;
  9983. this.values = collection_1.ListWrapper.createFixedSize(len);
  9984. this.localPipes = collection_1.ListWrapper.createFixedSize(len);
  9985. this.prevContexts = collection_1.ListWrapper.createFixedSize(len);
  9986. this.changes = collection_1.ListWrapper.createFixedSize(len);
  9987. this.dehydrateDirectives(false);
  9988. }
  9989. DynamicChangeDetector.prototype.handleEventInternal = function (eventName, elIndex, locals) {
  9990. var _this = this;
  9991. var preventDefault = false;
  9992. this._matchingEventBindings(eventName, elIndex)
  9993. .forEach(function (rec) {
  9994. var res = _this._processEventBinding(rec, locals);
  9995. if (res === false) {
  9996. preventDefault = true;
  9997. }
  9998. });
  9999. return preventDefault;
  10000. };
  10001. /** @internal */
  10002. DynamicChangeDetector.prototype._processEventBinding = function (eb, locals) {
  10003. var values = collection_1.ListWrapper.createFixedSize(eb.records.length);
  10004. values[0] = this.values[0];
  10005. for (var protoIdx = 0; protoIdx < eb.records.length; ++protoIdx) {
  10006. var proto = eb.records[protoIdx];
  10007. if (proto.isSkipRecord()) {
  10008. protoIdx += this._computeSkipLength(protoIdx, proto, values);
  10009. }
  10010. else {
  10011. var res = this._calculateCurrValue(proto, values, locals);
  10012. if (proto.lastInBinding) {
  10013. this._markPathAsCheckOnce(proto);
  10014. return res;
  10015. }
  10016. else {
  10017. this._writeSelf(proto, res, values);
  10018. }
  10019. }
  10020. }
  10021. throw new exceptions_1.BaseException("Cannot be reached");
  10022. };
  10023. DynamicChangeDetector.prototype._computeSkipLength = function (protoIndex, proto, values) {
  10024. if (proto.mode === proto_record_1.RecordType.SkipRecords) {
  10025. return proto.fixedArgs[0] - protoIndex - 1;
  10026. }
  10027. if (proto.mode === proto_record_1.RecordType.SkipRecordsIf) {
  10028. var condition = this._readContext(proto, values);
  10029. return condition ? proto.fixedArgs[0] - protoIndex - 1 : 0;
  10030. }
  10031. if (proto.mode === proto_record_1.RecordType.SkipRecordsIfNot) {
  10032. var condition = this._readContext(proto, values);
  10033. return condition ? 0 : proto.fixedArgs[0] - protoIndex - 1;
  10034. }
  10035. throw new exceptions_1.BaseException("Cannot be reached");
  10036. };
  10037. /** @internal */
  10038. DynamicChangeDetector.prototype._markPathAsCheckOnce = function (proto) {
  10039. if (!proto.bindingRecord.isDefaultChangeDetection()) {
  10040. var dir = proto.bindingRecord.directiveRecord;
  10041. this._getDetectorFor(dir.directiveIndex).markPathToRootAsCheckOnce();
  10042. }
  10043. };
  10044. /** @internal */
  10045. DynamicChangeDetector.prototype._matchingEventBindings = function (eventName, elIndex) {
  10046. return this._eventBindings.filter(function (eb) { return eb.eventName == eventName && eb.elIndex === elIndex; });
  10047. };
  10048. DynamicChangeDetector.prototype.hydrateDirectives = function (directives) {
  10049. this.values[0] = this.context;
  10050. this.directives = directives;
  10051. if (this.strategy === constants_1.ChangeDetectionStrategy.OnPushObserve) {
  10052. for (var i = 0; i < this.directiveIndices.length; ++i) {
  10053. var index = this.directiveIndices[i];
  10054. _super.prototype.observeDirective.call(this, directives.getDirectiveFor(index), i);
  10055. }
  10056. }
  10057. };
  10058. DynamicChangeDetector.prototype.dehydrateDirectives = function (destroyPipes) {
  10059. if (destroyPipes) {
  10060. this._destroyPipes();
  10061. }
  10062. this.values[0] = null;
  10063. this.directives = null;
  10064. collection_1.ListWrapper.fill(this.values, change_detection_util_1.ChangeDetectionUtil.uninitialized, 1);
  10065. collection_1.ListWrapper.fill(this.changes, false);
  10066. collection_1.ListWrapper.fill(this.localPipes, null);
  10067. collection_1.ListWrapper.fill(this.prevContexts, change_detection_util_1.ChangeDetectionUtil.uninitialized);
  10068. };
  10069. /** @internal */
  10070. DynamicChangeDetector.prototype._destroyPipes = function () {
  10071. for (var i = 0; i < this.localPipes.length; ++i) {
  10072. if (lang_1.isPresent(this.localPipes[i])) {
  10073. change_detection_util_1.ChangeDetectionUtil.callPipeOnDestroy(this.localPipes[i]);
  10074. }
  10075. }
  10076. };
  10077. DynamicChangeDetector.prototype.checkNoChanges = function () { this.runDetectChanges(true); };
  10078. DynamicChangeDetector.prototype.detectChangesInRecordsInternal = function (throwOnChange) {
  10079. var protos = this._records;
  10080. var changes = null;
  10081. var isChanged = false;
  10082. for (var protoIdx = 0; protoIdx < protos.length; ++protoIdx) {
  10083. var proto = protos[protoIdx];
  10084. var bindingRecord = proto.bindingRecord;
  10085. var directiveRecord = bindingRecord.directiveRecord;
  10086. if (this._firstInBinding(proto)) {
  10087. this.propertyBindingIndex = proto.propertyBindingIndex;
  10088. }
  10089. if (proto.isLifeCycleRecord()) {
  10090. if (proto.name === "DoCheck" && !throwOnChange) {
  10091. this._getDirectiveFor(directiveRecord.directiveIndex).ngDoCheck();
  10092. }
  10093. else if (proto.name === "OnInit" && !throwOnChange &&
  10094. this.state == constants_1.ChangeDetectorState.NeverChecked) {
  10095. this._getDirectiveFor(directiveRecord.directiveIndex).ngOnInit();
  10096. }
  10097. else if (proto.name === "OnChanges" && lang_1.isPresent(changes) && !throwOnChange) {
  10098. this._getDirectiveFor(directiveRecord.directiveIndex).ngOnChanges(changes);
  10099. }
  10100. }
  10101. else if (proto.isSkipRecord()) {
  10102. protoIdx += this._computeSkipLength(protoIdx, proto, this.values);
  10103. }
  10104. else {
  10105. var change = this._check(proto, throwOnChange, this.values, this.locals);
  10106. if (lang_1.isPresent(change)) {
  10107. this._updateDirectiveOrElement(change, bindingRecord);
  10108. isChanged = true;
  10109. changes = this._addChange(bindingRecord, change, changes);
  10110. }
  10111. }
  10112. if (proto.lastInDirective) {
  10113. changes = null;
  10114. if (isChanged && !bindingRecord.isDefaultChangeDetection()) {
  10115. this._getDetectorFor(directiveRecord.directiveIndex).markAsCheckOnce();
  10116. }
  10117. isChanged = false;
  10118. }
  10119. }
  10120. };
  10121. /** @internal */
  10122. DynamicChangeDetector.prototype._firstInBinding = function (r) {
  10123. var prev = change_detection_util_1.ChangeDetectionUtil.protoByIndex(this._records, r.selfIndex - 1);
  10124. return lang_1.isBlank(prev) || prev.bindingRecord !== r.bindingRecord;
  10125. };
  10126. DynamicChangeDetector.prototype.afterContentLifecycleCallbacksInternal = function () {
  10127. var dirs = this._directiveRecords;
  10128. for (var i = dirs.length - 1; i >= 0; --i) {
  10129. var dir = dirs[i];
  10130. if (dir.callAfterContentInit && this.state == constants_1.ChangeDetectorState.NeverChecked) {
  10131. this._getDirectiveFor(dir.directiveIndex).ngAfterContentInit();
  10132. }
  10133. if (dir.callAfterContentChecked) {
  10134. this._getDirectiveFor(dir.directiveIndex).ngAfterContentChecked();
  10135. }
  10136. }
  10137. };
  10138. DynamicChangeDetector.prototype.afterViewLifecycleCallbacksInternal = function () {
  10139. var dirs = this._directiveRecords;
  10140. for (var i = dirs.length - 1; i >= 0; --i) {
  10141. var dir = dirs[i];
  10142. if (dir.callAfterViewInit && this.state == constants_1.ChangeDetectorState.NeverChecked) {
  10143. this._getDirectiveFor(dir.directiveIndex).ngAfterViewInit();
  10144. }
  10145. if (dir.callAfterViewChecked) {
  10146. this._getDirectiveFor(dir.directiveIndex).ngAfterViewChecked();
  10147. }
  10148. }
  10149. };
  10150. /** @internal */
  10151. DynamicChangeDetector.prototype._updateDirectiveOrElement = function (change, bindingRecord) {
  10152. if (lang_1.isBlank(bindingRecord.directiveRecord)) {
  10153. _super.prototype.notifyDispatcher.call(this, change.currentValue);
  10154. }
  10155. else {
  10156. var directiveIndex = bindingRecord.directiveRecord.directiveIndex;
  10157. bindingRecord.setter(this._getDirectiveFor(directiveIndex), change.currentValue);
  10158. }
  10159. if (this._genConfig.logBindingUpdate) {
  10160. _super.prototype.logBindingUpdate.call(this, change.currentValue);
  10161. }
  10162. };
  10163. /** @internal */
  10164. DynamicChangeDetector.prototype._addChange = function (bindingRecord, change, changes) {
  10165. if (bindingRecord.callOnChanges()) {
  10166. return _super.prototype.addChange.call(this, changes, change.previousValue, change.currentValue);
  10167. }
  10168. else {
  10169. return changes;
  10170. }
  10171. };
  10172. /** @internal */
  10173. DynamicChangeDetector.prototype._getDirectiveFor = function (directiveIndex) {
  10174. return this.directives.getDirectiveFor(directiveIndex);
  10175. };
  10176. /** @internal */
  10177. DynamicChangeDetector.prototype._getDetectorFor = function (directiveIndex) { return this.directives.getDetectorFor(directiveIndex); };
  10178. /** @internal */
  10179. DynamicChangeDetector.prototype._check = function (proto, throwOnChange, values, locals) {
  10180. if (proto.isPipeRecord()) {
  10181. return this._pipeCheck(proto, throwOnChange, values);
  10182. }
  10183. else {
  10184. return this._referenceCheck(proto, throwOnChange, values, locals);
  10185. }
  10186. };
  10187. /** @internal */
  10188. DynamicChangeDetector.prototype._referenceCheck = function (proto, throwOnChange, values, locals) {
  10189. if (this._pureFuncAndArgsDidNotChange(proto)) {
  10190. this._setChanged(proto, false);
  10191. return null;
  10192. }
  10193. var currValue = this._calculateCurrValue(proto, values, locals);
  10194. if (this.strategy === constants_1.ChangeDetectionStrategy.OnPushObserve) {
  10195. _super.prototype.observeValue.call(this, currValue, proto.selfIndex);
  10196. }
  10197. if (proto.shouldBeChecked()) {
  10198. var prevValue = this._readSelf(proto, values);
  10199. if (change_detection_util_1.ChangeDetectionUtil.looseNotIdentical(prevValue, currValue)) {
  10200. if (proto.lastInBinding) {
  10201. var change = change_detection_util_1.ChangeDetectionUtil.simpleChange(prevValue, currValue);
  10202. if (throwOnChange)
  10203. this.throwOnChangeError(prevValue, currValue);
  10204. this._writeSelf(proto, currValue, values);
  10205. this._setChanged(proto, true);
  10206. return change;
  10207. }
  10208. else {
  10209. this._writeSelf(proto, currValue, values);
  10210. this._setChanged(proto, true);
  10211. return null;
  10212. }
  10213. }
  10214. else {
  10215. this._setChanged(proto, false);
  10216. return null;
  10217. }
  10218. }
  10219. else {
  10220. this._writeSelf(proto, currValue, values);
  10221. this._setChanged(proto, true);
  10222. return null;
  10223. }
  10224. };
  10225. DynamicChangeDetector.prototype._calculateCurrValue = function (proto, values, locals) {
  10226. switch (proto.mode) {
  10227. case proto_record_1.RecordType.Self:
  10228. return this._readContext(proto, values);
  10229. case proto_record_1.RecordType.Const:
  10230. return proto.funcOrValue;
  10231. case proto_record_1.RecordType.PropertyRead:
  10232. var context = this._readContext(proto, values);
  10233. return proto.funcOrValue(context);
  10234. case proto_record_1.RecordType.SafeProperty:
  10235. var context = this._readContext(proto, values);
  10236. return lang_1.isBlank(context) ? null : proto.funcOrValue(context);
  10237. case proto_record_1.RecordType.PropertyWrite:
  10238. var context = this._readContext(proto, values);
  10239. var value = this._readArgs(proto, values)[0];
  10240. proto.funcOrValue(context, value);
  10241. return value;
  10242. case proto_record_1.RecordType.KeyedWrite:
  10243. var context = this._readContext(proto, values);
  10244. var key = this._readArgs(proto, values)[0];
  10245. var value = this._readArgs(proto, values)[1];
  10246. context[key] = value;
  10247. return value;
  10248. case proto_record_1.RecordType.Local:
  10249. return locals.get(proto.name);
  10250. case proto_record_1.RecordType.InvokeMethod:
  10251. var context = this._readContext(proto, values);
  10252. var args = this._readArgs(proto, values);
  10253. return proto.funcOrValue(context, args);
  10254. case proto_record_1.RecordType.SafeMethodInvoke:
  10255. var context = this._readContext(proto, values);
  10256. if (lang_1.isBlank(context)) {
  10257. return null;
  10258. }
  10259. var args = this._readArgs(proto, values);
  10260. return proto.funcOrValue(context, args);
  10261. case proto_record_1.RecordType.KeyedRead:
  10262. var arg = this._readArgs(proto, values)[0];
  10263. return this._readContext(proto, values)[arg];
  10264. case proto_record_1.RecordType.Chain:
  10265. var args = this._readArgs(proto, values);
  10266. return args[args.length - 1];
  10267. case proto_record_1.RecordType.InvokeClosure:
  10268. return lang_1.FunctionWrapper.apply(this._readContext(proto, values), this._readArgs(proto, values));
  10269. case proto_record_1.RecordType.Interpolate:
  10270. case proto_record_1.RecordType.PrimitiveOp:
  10271. case proto_record_1.RecordType.CollectionLiteral:
  10272. return lang_1.FunctionWrapper.apply(proto.funcOrValue, this._readArgs(proto, values));
  10273. default:
  10274. throw new exceptions_1.BaseException("Unknown operation " + proto.mode);
  10275. }
  10276. };
  10277. DynamicChangeDetector.prototype._pipeCheck = function (proto, throwOnChange, values) {
  10278. var context = this._readContext(proto, values);
  10279. var selectedPipe = this._pipeFor(proto, context);
  10280. if (!selectedPipe.pure || this._argsOrContextChanged(proto)) {
  10281. var args = this._readArgs(proto, values);
  10282. var currValue = selectedPipe.pipe.transform(context, args);
  10283. if (proto.shouldBeChecked()) {
  10284. var prevValue = this._readSelf(proto, values);
  10285. if (change_detection_util_1.ChangeDetectionUtil.looseNotIdentical(prevValue, currValue)) {
  10286. currValue = change_detection_util_1.ChangeDetectionUtil.unwrapValue(currValue);
  10287. if (proto.lastInBinding) {
  10288. var change = change_detection_util_1.ChangeDetectionUtil.simpleChange(prevValue, currValue);
  10289. if (throwOnChange)
  10290. this.throwOnChangeError(prevValue, currValue);
  10291. this._writeSelf(proto, currValue, values);
  10292. this._setChanged(proto, true);
  10293. return change;
  10294. }
  10295. else {
  10296. this._writeSelf(proto, currValue, values);
  10297. this._setChanged(proto, true);
  10298. return null;
  10299. }
  10300. }
  10301. else {
  10302. this._setChanged(proto, false);
  10303. return null;
  10304. }
  10305. }
  10306. else {
  10307. this._writeSelf(proto, currValue, values);
  10308. this._setChanged(proto, true);
  10309. return null;
  10310. }
  10311. }
  10312. };
  10313. DynamicChangeDetector.prototype._pipeFor = function (proto, context) {
  10314. var storedPipe = this._readPipe(proto);
  10315. if (lang_1.isPresent(storedPipe))
  10316. return storedPipe;
  10317. var pipe = this.pipes.get(proto.name);
  10318. this._writePipe(proto, pipe);
  10319. return pipe;
  10320. };
  10321. DynamicChangeDetector.prototype._readContext = function (proto, values) {
  10322. if (proto.contextIndex == -1) {
  10323. return this._getDirectiveFor(proto.directiveIndex);
  10324. }
  10325. return values[proto.contextIndex];
  10326. };
  10327. DynamicChangeDetector.prototype._readSelf = function (proto, values) { return values[proto.selfIndex]; };
  10328. DynamicChangeDetector.prototype._writeSelf = function (proto, value, values) { values[proto.selfIndex] = value; };
  10329. DynamicChangeDetector.prototype._readPipe = function (proto) { return this.localPipes[proto.selfIndex]; };
  10330. DynamicChangeDetector.prototype._writePipe = function (proto, value) { this.localPipes[proto.selfIndex] = value; };
  10331. DynamicChangeDetector.prototype._setChanged = function (proto, value) {
  10332. if (proto.argumentToPureFunction)
  10333. this.changes[proto.selfIndex] = value;
  10334. };
  10335. DynamicChangeDetector.prototype._pureFuncAndArgsDidNotChange = function (proto) {
  10336. return proto.isPureFunction() && !this._argsChanged(proto);
  10337. };
  10338. DynamicChangeDetector.prototype._argsChanged = function (proto) {
  10339. var args = proto.args;
  10340. for (var i = 0; i < args.length; ++i) {
  10341. if (this.changes[args[i]]) {
  10342. return true;
  10343. }
  10344. }
  10345. return false;
  10346. };
  10347. DynamicChangeDetector.prototype._argsOrContextChanged = function (proto) {
  10348. return this._argsChanged(proto) || this.changes[proto.contextIndex];
  10349. };
  10350. DynamicChangeDetector.prototype._readArgs = function (proto, values) {
  10351. var res = collection_1.ListWrapper.createFixedSize(proto.args.length);
  10352. var args = proto.args;
  10353. for (var i = 0; i < args.length; ++i) {
  10354. res[i] = values[args[i]];
  10355. }
  10356. return res;
  10357. };
  10358. return DynamicChangeDetector;
  10359. })(abstract_change_detector_1.AbstractChangeDetector);
  10360. exports.DynamicChangeDetector = DynamicChangeDetector;
  10361. /***/ },
  10362. /* 43 */
  10363. /***/ function(module, exports, __webpack_require__) {
  10364. var lang_1 = __webpack_require__(5);
  10365. var collection_1 = __webpack_require__(12);
  10366. var change_detection_util_1 = __webpack_require__(38);
  10367. var change_detector_ref_1 = __webpack_require__(44);
  10368. var exceptions_1 = __webpack_require__(34);
  10369. var constants_1 = __webpack_require__(36);
  10370. var profile_1 = __webpack_require__(45);
  10371. var observable_facade_1 = __webpack_require__(47);
  10372. var _scope_check = profile_1.wtfCreateScope("ChangeDetector#check(ascii id, bool throwOnChange)");
  10373. var _Context = (function () {
  10374. function _Context(element, componentElement, context, locals, injector, expression) {
  10375. this.element = element;
  10376. this.componentElement = componentElement;
  10377. this.context = context;
  10378. this.locals = locals;
  10379. this.injector = injector;
  10380. this.expression = expression;
  10381. }
  10382. return _Context;
  10383. })();
  10384. var AbstractChangeDetector = (function () {
  10385. function AbstractChangeDetector(id, dispatcher, numberOfPropertyProtoRecords, bindingTargets, directiveIndices, strategy) {
  10386. this.id = id;
  10387. this.dispatcher = dispatcher;
  10388. this.numberOfPropertyProtoRecords = numberOfPropertyProtoRecords;
  10389. this.bindingTargets = bindingTargets;
  10390. this.directiveIndices = directiveIndices;
  10391. this.strategy = strategy;
  10392. this.contentChildren = [];
  10393. this.viewChildren = [];
  10394. // The names of the below fields must be kept in sync with codegen_name_util.ts or
  10395. // change detection will fail.
  10396. this.state = constants_1.ChangeDetectorState.NeverChecked;
  10397. this.locals = null;
  10398. this.mode = null;
  10399. this.pipes = null;
  10400. this.ref = new change_detector_ref_1.ChangeDetectorRef_(this);
  10401. }
  10402. AbstractChangeDetector.prototype.addContentChild = function (cd) {
  10403. this.contentChildren.push(cd);
  10404. cd.parent = this;
  10405. };
  10406. AbstractChangeDetector.prototype.removeContentChild = function (cd) { collection_1.ListWrapper.remove(this.contentChildren, cd); };
  10407. AbstractChangeDetector.prototype.addViewChild = function (cd) {
  10408. this.viewChildren.push(cd);
  10409. cd.parent = this;
  10410. };
  10411. AbstractChangeDetector.prototype.removeViewChild = function (cd) { collection_1.ListWrapper.remove(this.viewChildren, cd); };
  10412. AbstractChangeDetector.prototype.remove = function () { this.parent.removeContentChild(this); };
  10413. AbstractChangeDetector.prototype.handleEvent = function (eventName, elIndex, locals) {
  10414. var res = this.handleEventInternal(eventName, elIndex, locals);
  10415. this.markPathToRootAsCheckOnce();
  10416. return res;
  10417. };
  10418. AbstractChangeDetector.prototype.handleEventInternal = function (eventName, elIndex, locals) { return false; };
  10419. AbstractChangeDetector.prototype.detectChanges = function () { this.runDetectChanges(false); };
  10420. AbstractChangeDetector.prototype.checkNoChanges = function () {
  10421. if (lang_1.assertionsEnabled()) {
  10422. this.runDetectChanges(true);
  10423. }
  10424. };
  10425. AbstractChangeDetector.prototype.runDetectChanges = function (throwOnChange) {
  10426. if (this.mode === constants_1.ChangeDetectionStrategy.Detached ||
  10427. this.mode === constants_1.ChangeDetectionStrategy.Checked || this.state === constants_1.ChangeDetectorState.Errored)
  10428. return;
  10429. var s = _scope_check(this.id, throwOnChange);
  10430. this.detectChangesInRecords(throwOnChange);
  10431. this._detectChangesContentChildren(throwOnChange);
  10432. if (!throwOnChange)
  10433. this.afterContentLifecycleCallbacks();
  10434. this._detectChangesInViewChildren(throwOnChange);
  10435. if (!throwOnChange)
  10436. this.afterViewLifecycleCallbacks();
  10437. if (this.mode === constants_1.ChangeDetectionStrategy.CheckOnce)
  10438. this.mode = constants_1.ChangeDetectionStrategy.Checked;
  10439. this.state = constants_1.ChangeDetectorState.CheckedBefore;
  10440. profile_1.wtfLeave(s);
  10441. };
  10442. // This method is not intended to be overridden. Subclasses should instead provide an
  10443. // implementation of `detectChangesInRecordsInternal` which does the work of detecting changes
  10444. // and which this method will call.
  10445. // This method expects that `detectChangesInRecordsInternal` will set the property
  10446. // `this.propertyBindingIndex` to the propertyBindingIndex of the first proto record. This is to
  10447. // facilitate error reporting.
  10448. AbstractChangeDetector.prototype.detectChangesInRecords = function (throwOnChange) {
  10449. if (!this.hydrated()) {
  10450. this.throwDehydratedError();
  10451. }
  10452. try {
  10453. this.detectChangesInRecordsInternal(throwOnChange);
  10454. }
  10455. catch (e) {
  10456. // throwOnChange errors aren't counted as fatal errors.
  10457. if (!(e instanceof exceptions_1.ExpressionChangedAfterItHasBeenCheckedException)) {
  10458. this.state = constants_1.ChangeDetectorState.Errored;
  10459. }
  10460. this._throwError(e, e.stack);
  10461. }
  10462. };
  10463. // Subclasses should override this method to perform any work necessary to detect and report
  10464. // changes. For example, changes should be reported via `ChangeDetectionUtil.addChange`, lifecycle
  10465. // methods should be called, etc.
  10466. // This implementation should also set `this.propertyBindingIndex` to the propertyBindingIndex of
  10467. // the
  10468. // first proto record to facilitate error reporting. See {@link #detectChangesInRecords}.
  10469. AbstractChangeDetector.prototype.detectChangesInRecordsInternal = function (throwOnChange) { };
  10470. // This method is not intended to be overridden. Subclasses should instead provide an
  10471. // implementation of `hydrateDirectives`.
  10472. AbstractChangeDetector.prototype.hydrate = function (context, locals, directives, pipes) {
  10473. this.mode = change_detection_util_1.ChangeDetectionUtil.changeDetectionMode(this.strategy);
  10474. this.context = context;
  10475. if (this.strategy === constants_1.ChangeDetectionStrategy.OnPushObserve) {
  10476. this.observeComponent(context);
  10477. }
  10478. this.locals = locals;
  10479. this.pipes = pipes;
  10480. this.hydrateDirectives(directives);
  10481. this.state = constants_1.ChangeDetectorState.NeverChecked;
  10482. };
  10483. // Subclasses should override this method to hydrate any directives.
  10484. AbstractChangeDetector.prototype.hydrateDirectives = function (directives) { };
  10485. // This method is not intended to be overridden. Subclasses should instead provide an
  10486. // implementation of `dehydrateDirectives`.
  10487. AbstractChangeDetector.prototype.dehydrate = function () {
  10488. this.dehydrateDirectives(true);
  10489. // This is an experimental feature. Works only in Dart.
  10490. if (this.strategy === constants_1.ChangeDetectionStrategy.OnPushObserve) {
  10491. this._unsubsribeFromObservables();
  10492. }
  10493. this.context = null;
  10494. this.locals = null;
  10495. this.pipes = null;
  10496. };
  10497. // Subclasses should override this method to dehydrate any directives. This method should reverse
  10498. // any work done in `hydrateDirectives`.
  10499. AbstractChangeDetector.prototype.dehydrateDirectives = function (destroyPipes) { };
  10500. AbstractChangeDetector.prototype.hydrated = function () { return lang_1.isPresent(this.context); };
  10501. AbstractChangeDetector.prototype.afterContentLifecycleCallbacks = function () {
  10502. this.dispatcher.notifyAfterContentChecked();
  10503. this.afterContentLifecycleCallbacksInternal();
  10504. };
  10505. AbstractChangeDetector.prototype.afterContentLifecycleCallbacksInternal = function () { };
  10506. AbstractChangeDetector.prototype.afterViewLifecycleCallbacks = function () {
  10507. this.dispatcher.notifyAfterViewChecked();
  10508. this.afterViewLifecycleCallbacksInternal();
  10509. };
  10510. AbstractChangeDetector.prototype.afterViewLifecycleCallbacksInternal = function () { };
  10511. /** @internal */
  10512. AbstractChangeDetector.prototype._detectChangesContentChildren = function (throwOnChange) {
  10513. var c = this.contentChildren;
  10514. for (var i = 0; i < c.length; ++i) {
  10515. c[i].runDetectChanges(throwOnChange);
  10516. }
  10517. };
  10518. /** @internal */
  10519. AbstractChangeDetector.prototype._detectChangesInViewChildren = function (throwOnChange) {
  10520. var c = this.viewChildren;
  10521. for (var i = 0; i < c.length; ++i) {
  10522. c[i].runDetectChanges(throwOnChange);
  10523. }
  10524. };
  10525. AbstractChangeDetector.prototype.markAsCheckOnce = function () { this.mode = constants_1.ChangeDetectionStrategy.CheckOnce; };
  10526. AbstractChangeDetector.prototype.markPathToRootAsCheckOnce = function () {
  10527. var c = this;
  10528. while (lang_1.isPresent(c) && c.mode !== constants_1.ChangeDetectionStrategy.Detached) {
  10529. if (c.mode === constants_1.ChangeDetectionStrategy.Checked)
  10530. c.mode = constants_1.ChangeDetectionStrategy.CheckOnce;
  10531. c = c.parent;
  10532. }
  10533. };
  10534. // This is an experimental feature. Works only in Dart.
  10535. AbstractChangeDetector.prototype._unsubsribeFromObservables = function () {
  10536. if (lang_1.isPresent(this.subscriptions)) {
  10537. for (var i = 0; i < this.subscriptions.length; ++i) {
  10538. var s = this.subscriptions[i];
  10539. if (lang_1.isPresent(this.subscriptions[i])) {
  10540. s.cancel();
  10541. this.subscriptions[i] = null;
  10542. }
  10543. }
  10544. }
  10545. };
  10546. // This is an experimental feature. Works only in Dart.
  10547. AbstractChangeDetector.prototype.observeValue = function (value, index) {
  10548. var _this = this;
  10549. if (observable_facade_1.isObservable(value)) {
  10550. this._createArrayToStoreObservables();
  10551. if (lang_1.isBlank(this.subscriptions[index])) {
  10552. this.streams[index] = value.changes;
  10553. this.subscriptions[index] = value.changes.listen(function (_) { return _this.ref.markForCheck(); });
  10554. }
  10555. else if (this.streams[index] !== value.changes) {
  10556. this.subscriptions[index].cancel();
  10557. this.streams[index] = value.changes;
  10558. this.subscriptions[index] = value.changes.listen(function (_) { return _this.ref.markForCheck(); });
  10559. }
  10560. }
  10561. return value;
  10562. };
  10563. // This is an experimental feature. Works only in Dart.
  10564. AbstractChangeDetector.prototype.observeDirective = function (value, index) {
  10565. var _this = this;
  10566. if (observable_facade_1.isObservable(value)) {
  10567. this._createArrayToStoreObservables();
  10568. var arrayIndex = this.numberOfPropertyProtoRecords + index + 2; // +1 is component
  10569. this.streams[arrayIndex] = value.changes;
  10570. this.subscriptions[arrayIndex] = value.changes.listen(function (_) { return _this.ref.markForCheck(); });
  10571. }
  10572. return value;
  10573. };
  10574. // This is an experimental feature. Works only in Dart.
  10575. AbstractChangeDetector.prototype.observeComponent = function (value) {
  10576. var _this = this;
  10577. if (observable_facade_1.isObservable(value)) {
  10578. this._createArrayToStoreObservables();
  10579. var index = this.numberOfPropertyProtoRecords + 1;
  10580. this.streams[index] = value.changes;
  10581. this.subscriptions[index] = value.changes.listen(function (_) { return _this.ref.markForCheck(); });
  10582. }
  10583. return value;
  10584. };
  10585. AbstractChangeDetector.prototype._createArrayToStoreObservables = function () {
  10586. if (lang_1.isBlank(this.subscriptions)) {
  10587. this.subscriptions = collection_1.ListWrapper.createFixedSize(this.numberOfPropertyProtoRecords +
  10588. this.directiveIndices.length + 2);
  10589. this.streams = collection_1.ListWrapper.createFixedSize(this.numberOfPropertyProtoRecords +
  10590. this.directiveIndices.length + 2);
  10591. }
  10592. };
  10593. AbstractChangeDetector.prototype.getDirectiveFor = function (directives, index) {
  10594. return directives.getDirectiveFor(this.directiveIndices[index]);
  10595. };
  10596. AbstractChangeDetector.prototype.getDetectorFor = function (directives, index) {
  10597. return directives.getDetectorFor(this.directiveIndices[index]);
  10598. };
  10599. AbstractChangeDetector.prototype.notifyDispatcher = function (value) {
  10600. this.dispatcher.notifyOnBinding(this._currentBinding(), value);
  10601. };
  10602. AbstractChangeDetector.prototype.logBindingUpdate = function (value) {
  10603. this.dispatcher.logBindingUpdate(this._currentBinding(), value);
  10604. };
  10605. AbstractChangeDetector.prototype.addChange = function (changes, oldValue, newValue) {
  10606. if (lang_1.isBlank(changes)) {
  10607. changes = {};
  10608. }
  10609. changes[this._currentBinding().name] = change_detection_util_1.ChangeDetectionUtil.simpleChange(oldValue, newValue);
  10610. return changes;
  10611. };
  10612. AbstractChangeDetector.prototype._throwError = function (exception, stack) {
  10613. var error;
  10614. try {
  10615. var c = this.dispatcher.getDebugContext(this._currentBinding().elementIndex, null);
  10616. var context = lang_1.isPresent(c) ? new _Context(c.element, c.componentElement, c.context, c.locals, c.injector, this._currentBinding().debug) :
  10617. null;
  10618. error = new exceptions_1.ChangeDetectionError(this._currentBinding().debug, exception, stack, context);
  10619. }
  10620. catch (e) {
  10621. // if an error happens during getting the debug context, we throw a ChangeDetectionError
  10622. // without the extra information.
  10623. error = new exceptions_1.ChangeDetectionError(null, exception, stack, null);
  10624. }
  10625. throw error;
  10626. };
  10627. AbstractChangeDetector.prototype.throwOnChangeError = function (oldValue, newValue) {
  10628. throw new exceptions_1.ExpressionChangedAfterItHasBeenCheckedException(this._currentBinding().debug, oldValue, newValue, null);
  10629. };
  10630. AbstractChangeDetector.prototype.throwDehydratedError = function () { throw new exceptions_1.DehydratedException(); };
  10631. AbstractChangeDetector.prototype._currentBinding = function () {
  10632. return this.bindingTargets[this.propertyBindingIndex];
  10633. };
  10634. return AbstractChangeDetector;
  10635. })();
  10636. exports.AbstractChangeDetector = AbstractChangeDetector;
  10637. /***/ },
  10638. /* 44 */
  10639. /***/ function(module, exports, __webpack_require__) {
  10640. var __extends = (this && this.__extends) || function (d, b) {
  10641. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  10642. function __() { this.constructor = d; }
  10643. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10644. };
  10645. var constants_1 = __webpack_require__(36);
  10646. var ChangeDetectorRef = (function () {
  10647. function ChangeDetectorRef() {
  10648. }
  10649. return ChangeDetectorRef;
  10650. })();
  10651. exports.ChangeDetectorRef = ChangeDetectorRef;
  10652. var ChangeDetectorRef_ = (function (_super) {
  10653. __extends(ChangeDetectorRef_, _super);
  10654. function ChangeDetectorRef_(_cd) {
  10655. _super.call(this);
  10656. this._cd = _cd;
  10657. }
  10658. ChangeDetectorRef_.prototype.markForCheck = function () { this._cd.markPathToRootAsCheckOnce(); };
  10659. ChangeDetectorRef_.prototype.detach = function () { this._cd.mode = constants_1.ChangeDetectionStrategy.Detached; };
  10660. ChangeDetectorRef_.prototype.detectChanges = function () { this._cd.detectChanges(); };
  10661. ChangeDetectorRef_.prototype.checkNoChanges = function () { this._cd.checkNoChanges(); };
  10662. ChangeDetectorRef_.prototype.reattach = function () {
  10663. this._cd.mode = constants_1.ChangeDetectionStrategy.CheckAlways;
  10664. this.markForCheck();
  10665. };
  10666. return ChangeDetectorRef_;
  10667. })(ChangeDetectorRef);
  10668. exports.ChangeDetectorRef_ = ChangeDetectorRef_;
  10669. /***/ },
  10670. /* 45 */
  10671. /***/ function(module, exports, __webpack_require__) {
  10672. var impl = __webpack_require__(46);
  10673. // Change exports to const once https://github.com/angular/ts2dart/issues/150
  10674. /**
  10675. * True if WTF is enabled.
  10676. */
  10677. exports.wtfEnabled = impl.detectWTF();
  10678. function noopScope(arg0, arg1) {
  10679. return null;
  10680. }
  10681. /**
  10682. * Create trace scope.
  10683. *
  10684. * Scopes must be strictly nested and are analogous to stack frames, but
  10685. * do not have to follow the stack frames. Instead it is recommended that they follow logical
  10686. * nesting. You may want to use
  10687. * [Event
  10688. * Signatures](http://google.github.io/tracing-framework/instrumenting-code.html#custom-events)
  10689. * as they are defined in WTF.
  10690. *
  10691. * Used to mark scope entry. The return value is used to leave the scope.
  10692. *
  10693. * var myScope = wtfCreateScope('MyClass#myMethod(ascii someVal)');
  10694. *
  10695. * someMethod() {
  10696. * var s = myScope('Foo'); // 'Foo' gets stored in tracing UI
  10697. * // DO SOME WORK HERE
  10698. * return wtfLeave(s, 123); // Return value 123
  10699. * }
  10700. *
  10701. * Note, adding try-finally block around the work to ensure that `wtfLeave` gets called can
  10702. * negatively impact the performance of your application. For this reason we recommend that
  10703. * you don't add them to ensure that `wtfLeave` gets called. In production `wtfLeave` is a noop and
  10704. * so try-finally block has no value. When debugging perf issues, skipping `wtfLeave`, do to
  10705. * exception, will produce incorrect trace, but presence of exception signifies logic error which
  10706. * needs to be fixed before the app should be profiled. Add try-finally only when you expect that
  10707. * an exception is expected during normal execution while profiling.
  10708. *
  10709. */
  10710. exports.wtfCreateScope = exports.wtfEnabled ? impl.createScope : function (signature, flags) { return noopScope; };
  10711. /**
  10712. * Used to mark end of Scope.
  10713. *
  10714. * - `scope` to end.
  10715. * - `returnValue` (optional) to be passed to the WTF.
  10716. *
  10717. * Returns the `returnValue for easy chaining.
  10718. */
  10719. exports.wtfLeave = exports.wtfEnabled ? impl.leave : function (s, r) { return r; };
  10720. /**
  10721. * Used to mark Async start. Async are similar to scope but they don't have to be strictly nested.
  10722. * The return value is used in the call to [endAsync]. Async ranges only work if WTF has been
  10723. * enabled.
  10724. *
  10725. * someMethod() {
  10726. * var s = wtfStartTimeRange('HTTP:GET', 'some.url');
  10727. * var future = new Future.delay(5).then((_) {
  10728. * wtfEndTimeRange(s);
  10729. * });
  10730. * }
  10731. */
  10732. exports.wtfStartTimeRange = exports.wtfEnabled ? impl.startTimeRange : function (rangeType, action) { return null; };
  10733. /**
  10734. * Ends a async time range operation.
  10735. * [range] is the return value from [wtfStartTimeRange] Async ranges only work if WTF has been
  10736. * enabled.
  10737. */
  10738. exports.wtfEndTimeRange = exports.wtfEnabled ? impl.endTimeRange : function (r) {
  10739. return null;
  10740. };
  10741. /***/ },
  10742. /* 46 */
  10743. /***/ function(module, exports, __webpack_require__) {
  10744. var lang_1 = __webpack_require__(5);
  10745. var trace;
  10746. var events;
  10747. function detectWTF() {
  10748. var wtf = lang_1.global['wtf'];
  10749. if (wtf) {
  10750. trace = wtf['trace'];
  10751. if (trace) {
  10752. events = trace['events'];
  10753. return true;
  10754. }
  10755. }
  10756. return false;
  10757. }
  10758. exports.detectWTF = detectWTF;
  10759. function createScope(signature, flags) {
  10760. if (flags === void 0) { flags = null; }
  10761. return events.createScope(signature, flags);
  10762. }
  10763. exports.createScope = createScope;
  10764. function leave(scope, returnValue) {
  10765. trace.leaveScope(scope, returnValue);
  10766. return returnValue;
  10767. }
  10768. exports.leave = leave;
  10769. function startTimeRange(rangeType, action) {
  10770. return trace.beginTimeRange(rangeType, action);
  10771. }
  10772. exports.startTimeRange = startTimeRange;
  10773. function endTimeRange(range) {
  10774. trace.endTimeRange(range);
  10775. }
  10776. exports.endTimeRange = endTimeRange;
  10777. /***/ },
  10778. /* 47 */
  10779. /***/ function(module, exports) {
  10780. function isObservable(value) {
  10781. return false;
  10782. }
  10783. exports.isObservable = isObservable;
  10784. /***/ },
  10785. /* 48 */
  10786. /***/ function(module, exports) {
  10787. (function (RecordType) {
  10788. RecordType[RecordType["Self"] = 0] = "Self";
  10789. RecordType[RecordType["Const"] = 1] = "Const";
  10790. RecordType[RecordType["PrimitiveOp"] = 2] = "PrimitiveOp";
  10791. RecordType[RecordType["PropertyRead"] = 3] = "PropertyRead";
  10792. RecordType[RecordType["PropertyWrite"] = 4] = "PropertyWrite";
  10793. RecordType[RecordType["Local"] = 5] = "Local";
  10794. RecordType[RecordType["InvokeMethod"] = 6] = "InvokeMethod";
  10795. RecordType[RecordType["InvokeClosure"] = 7] = "InvokeClosure";
  10796. RecordType[RecordType["KeyedRead"] = 8] = "KeyedRead";
  10797. RecordType[RecordType["KeyedWrite"] = 9] = "KeyedWrite";
  10798. RecordType[RecordType["Pipe"] = 10] = "Pipe";
  10799. RecordType[RecordType["Interpolate"] = 11] = "Interpolate";
  10800. RecordType[RecordType["SafeProperty"] = 12] = "SafeProperty";
  10801. RecordType[RecordType["CollectionLiteral"] = 13] = "CollectionLiteral";
  10802. RecordType[RecordType["SafeMethodInvoke"] = 14] = "SafeMethodInvoke";
  10803. RecordType[RecordType["DirectiveLifecycle"] = 15] = "DirectiveLifecycle";
  10804. RecordType[RecordType["Chain"] = 16] = "Chain";
  10805. RecordType[RecordType["SkipRecordsIf"] = 17] = "SkipRecordsIf";
  10806. RecordType[RecordType["SkipRecordsIfNot"] = 18] = "SkipRecordsIfNot";
  10807. RecordType[RecordType["SkipRecords"] = 19] = "SkipRecords"; // Skip records unconditionally
  10808. })(exports.RecordType || (exports.RecordType = {}));
  10809. var RecordType = exports.RecordType;
  10810. var ProtoRecord = (function () {
  10811. function ProtoRecord(mode, name, funcOrValue, args, fixedArgs, contextIndex, directiveIndex, selfIndex, bindingRecord, lastInBinding, lastInDirective, argumentToPureFunction, referencedBySelf, propertyBindingIndex) {
  10812. this.mode = mode;
  10813. this.name = name;
  10814. this.funcOrValue = funcOrValue;
  10815. this.args = args;
  10816. this.fixedArgs = fixedArgs;
  10817. this.contextIndex = contextIndex;
  10818. this.directiveIndex = directiveIndex;
  10819. this.selfIndex = selfIndex;
  10820. this.bindingRecord = bindingRecord;
  10821. this.lastInBinding = lastInBinding;
  10822. this.lastInDirective = lastInDirective;
  10823. this.argumentToPureFunction = argumentToPureFunction;
  10824. this.referencedBySelf = referencedBySelf;
  10825. this.propertyBindingIndex = propertyBindingIndex;
  10826. }
  10827. ProtoRecord.prototype.isPureFunction = function () {
  10828. return this.mode === RecordType.Interpolate || this.mode === RecordType.CollectionLiteral;
  10829. };
  10830. ProtoRecord.prototype.isUsedByOtherRecord = function () { return !this.lastInBinding || this.referencedBySelf; };
  10831. ProtoRecord.prototype.shouldBeChecked = function () {
  10832. return this.argumentToPureFunction || this.lastInBinding || this.isPureFunction() ||
  10833. this.isPipeRecord();
  10834. };
  10835. ProtoRecord.prototype.isPipeRecord = function () { return this.mode === RecordType.Pipe; };
  10836. ProtoRecord.prototype.isConditionalSkipRecord = function () {
  10837. return this.mode === RecordType.SkipRecordsIfNot || this.mode === RecordType.SkipRecordsIf;
  10838. };
  10839. ProtoRecord.prototype.isUnconditionalSkipRecord = function () { return this.mode === RecordType.SkipRecords; };
  10840. ProtoRecord.prototype.isSkipRecord = function () {
  10841. return this.isConditionalSkipRecord() || this.isUnconditionalSkipRecord();
  10842. };
  10843. ProtoRecord.prototype.isLifeCycleRecord = function () { return this.mode === RecordType.DirectiveLifecycle; };
  10844. return ProtoRecord;
  10845. })();
  10846. exports.ProtoRecord = ProtoRecord;
  10847. /***/ },
  10848. /* 49 */
  10849. /***/ function(module, exports) {
  10850. var EventBinding = (function () {
  10851. function EventBinding(eventName, elIndex, dirIndex, records) {
  10852. this.eventName = eventName;
  10853. this.elIndex = elIndex;
  10854. this.dirIndex = dirIndex;
  10855. this.records = records;
  10856. }
  10857. return EventBinding;
  10858. })();
  10859. exports.EventBinding = EventBinding;
  10860. /***/ },
  10861. /* 50 */
  10862. /***/ function(module, exports, __webpack_require__) {
  10863. var lang_1 = __webpack_require__(5);
  10864. var collection_1 = __webpack_require__(12);
  10865. var proto_record_1 = __webpack_require__(48);
  10866. /**
  10867. * Removes "duplicate" records. It assumes that record evaluation does not have side-effects.
  10868. *
  10869. * Records that are not last in bindings are removed and all the indices of the records that depend
  10870. * on them are updated.
  10871. *
  10872. * Records that are last in bindings CANNOT be removed, and instead are replaced with very cheap
  10873. * SELF records.
  10874. *
  10875. * @internal
  10876. */
  10877. function coalesce(srcRecords) {
  10878. var dstRecords = [];
  10879. var excludedIdxs = [];
  10880. var indexMap = new collection_1.Map();
  10881. var skipDepth = 0;
  10882. var skipSources = collection_1.ListWrapper.createFixedSize(srcRecords.length);
  10883. for (var protoIndex = 0; protoIndex < srcRecords.length; protoIndex++) {
  10884. var skipRecord = skipSources[protoIndex];
  10885. if (lang_1.isPresent(skipRecord)) {
  10886. skipDepth--;
  10887. skipRecord.fixedArgs[0] = dstRecords.length;
  10888. }
  10889. var src = srcRecords[protoIndex];
  10890. var dst = _cloneAndUpdateIndexes(src, dstRecords, indexMap);
  10891. if (dst.isSkipRecord()) {
  10892. dstRecords.push(dst);
  10893. skipDepth++;
  10894. skipSources[dst.fixedArgs[0]] = dst;
  10895. }
  10896. else {
  10897. var record = _mayBeAddRecord(dst, dstRecords, excludedIdxs, skipDepth > 0);
  10898. indexMap.set(src.selfIndex, record.selfIndex);
  10899. }
  10900. }
  10901. return _optimizeSkips(dstRecords);
  10902. }
  10903. exports.coalesce = coalesce;
  10904. /**
  10905. * - Conditional skip of 1 record followed by an unconditional skip of N are replaced by a
  10906. * conditional skip of N with the negated condition,
  10907. * - Skips of 0 records are removed
  10908. */
  10909. function _optimizeSkips(srcRecords) {
  10910. var dstRecords = [];
  10911. var skipSources = collection_1.ListWrapper.createFixedSize(srcRecords.length);
  10912. var indexMap = new collection_1.Map();
  10913. for (var protoIndex = 0; protoIndex < srcRecords.length; protoIndex++) {
  10914. var skipRecord = skipSources[protoIndex];
  10915. if (lang_1.isPresent(skipRecord)) {
  10916. skipRecord.fixedArgs[0] = dstRecords.length;
  10917. }
  10918. var src = srcRecords[protoIndex];
  10919. if (src.isSkipRecord()) {
  10920. if (src.isConditionalSkipRecord() && src.fixedArgs[0] === protoIndex + 2 &&
  10921. protoIndex < srcRecords.length - 1 &&
  10922. srcRecords[protoIndex + 1].mode === proto_record_1.RecordType.SkipRecords) {
  10923. src.mode = src.mode === proto_record_1.RecordType.SkipRecordsIf ? proto_record_1.RecordType.SkipRecordsIfNot :
  10924. proto_record_1.RecordType.SkipRecordsIf;
  10925. src.fixedArgs[0] = srcRecords[protoIndex + 1].fixedArgs[0];
  10926. protoIndex++;
  10927. }
  10928. if (src.fixedArgs[0] > protoIndex + 1) {
  10929. var dst = _cloneAndUpdateIndexes(src, dstRecords, indexMap);
  10930. dstRecords.push(dst);
  10931. skipSources[dst.fixedArgs[0]] = dst;
  10932. }
  10933. }
  10934. else {
  10935. var dst = _cloneAndUpdateIndexes(src, dstRecords, indexMap);
  10936. dstRecords.push(dst);
  10937. indexMap.set(src.selfIndex, dst.selfIndex);
  10938. }
  10939. }
  10940. return dstRecords;
  10941. }
  10942. /**
  10943. * Add a new record or re-use one of the existing records.
  10944. */
  10945. function _mayBeAddRecord(record, dstRecords, excludedIdxs, excluded) {
  10946. var match = _findFirstMatch(record, dstRecords, excludedIdxs);
  10947. if (lang_1.isPresent(match)) {
  10948. if (record.lastInBinding) {
  10949. dstRecords.push(_createSelfRecord(record, match.selfIndex, dstRecords.length + 1));
  10950. match.referencedBySelf = true;
  10951. }
  10952. else {
  10953. if (record.argumentToPureFunction) {
  10954. match.argumentToPureFunction = true;
  10955. }
  10956. }
  10957. return match;
  10958. }
  10959. if (excluded) {
  10960. excludedIdxs.push(record.selfIndex);
  10961. }
  10962. dstRecords.push(record);
  10963. return record;
  10964. }
  10965. /**
  10966. * Returns the first `ProtoRecord` that matches the record.
  10967. */
  10968. function _findFirstMatch(record, dstRecords, excludedIdxs) {
  10969. return dstRecords.find(
  10970. // TODO(vicb): optimize excludedIdxs.indexOf (sorted array)
  10971. function (rr) { return excludedIdxs.indexOf(rr.selfIndex) == -1 && rr.mode !== proto_record_1.RecordType.DirectiveLifecycle &&
  10972. _haveSameDirIndex(rr, record) && rr.mode === record.mode &&
  10973. lang_1.looseIdentical(rr.funcOrValue, record.funcOrValue) &&
  10974. rr.contextIndex === record.contextIndex && lang_1.looseIdentical(rr.name, record.name) &&
  10975. collection_1.ListWrapper.equals(rr.args, record.args); });
  10976. }
  10977. /**
  10978. * Clone the `ProtoRecord` and changes the indexes for the ones in the destination array for:
  10979. * - the arguments,
  10980. * - the context,
  10981. * - self
  10982. */
  10983. function _cloneAndUpdateIndexes(record, dstRecords, indexMap) {
  10984. var args = record.args.map(function (src) { return _srcToDstSelfIndex(indexMap, src); });
  10985. var contextIndex = _srcToDstSelfIndex(indexMap, record.contextIndex);
  10986. var selfIndex = dstRecords.length + 1;
  10987. return new proto_record_1.ProtoRecord(record.mode, record.name, record.funcOrValue, args, record.fixedArgs, contextIndex, record.directiveIndex, selfIndex, record.bindingRecord, record.lastInBinding, record.lastInDirective, record.argumentToPureFunction, record.referencedBySelf, record.propertyBindingIndex);
  10988. }
  10989. /**
  10990. * Returns the index in the destination array corresponding to the index in the src array.
  10991. * When the element is not present in the destination array, return the source index.
  10992. */
  10993. function _srcToDstSelfIndex(indexMap, srcIdx) {
  10994. var dstIdx = indexMap.get(srcIdx);
  10995. return lang_1.isPresent(dstIdx) ? dstIdx : srcIdx;
  10996. }
  10997. function _createSelfRecord(r, contextIndex, selfIndex) {
  10998. return new proto_record_1.ProtoRecord(proto_record_1.RecordType.Self, "self", null, [], r.fixedArgs, contextIndex, r.directiveIndex, selfIndex, r.bindingRecord, r.lastInBinding, r.lastInDirective, false, false, r.propertyBindingIndex);
  10999. }
  11000. function _haveSameDirIndex(a, b) {
  11001. var di1 = lang_1.isBlank(a.directiveIndex) ? null : a.directiveIndex.directiveIndex;
  11002. var ei1 = lang_1.isBlank(a.directiveIndex) ? null : a.directiveIndex.elementIndex;
  11003. var di2 = lang_1.isBlank(b.directiveIndex) ? null : b.directiveIndex.directiveIndex;
  11004. var ei2 = lang_1.isBlank(b.directiveIndex) ? null : b.directiveIndex.elementIndex;
  11005. return di1 === di2 && ei1 === ei2;
  11006. }
  11007. /***/ },
  11008. /* 51 */
  11009. /***/ function(module, exports, __webpack_require__) {
  11010. var change_detection_jit_generator_1 = __webpack_require__(52);
  11011. var JitProtoChangeDetector = (function () {
  11012. function JitProtoChangeDetector(definition) {
  11013. this.definition = definition;
  11014. this._factory = this._createFactory(definition);
  11015. }
  11016. JitProtoChangeDetector.isSupported = function () { return true; };
  11017. JitProtoChangeDetector.prototype.instantiate = function (dispatcher) { return this._factory(dispatcher); };
  11018. /** @internal */
  11019. JitProtoChangeDetector.prototype._createFactory = function (definition) {
  11020. return new change_detection_jit_generator_1.ChangeDetectorJITGenerator(definition, 'util', 'AbstractChangeDetector', 'ChangeDetectorStatus')
  11021. .generate();
  11022. };
  11023. return JitProtoChangeDetector;
  11024. })();
  11025. exports.JitProtoChangeDetector = JitProtoChangeDetector;
  11026. /***/ },
  11027. /* 52 */
  11028. /***/ function(module, exports, __webpack_require__) {
  11029. var lang_1 = __webpack_require__(5);
  11030. var exceptions_1 = __webpack_require__(14);
  11031. var collection_1 = __webpack_require__(12);
  11032. var abstract_change_detector_1 = __webpack_require__(43);
  11033. var change_detection_util_1 = __webpack_require__(38);
  11034. var proto_record_1 = __webpack_require__(48);
  11035. var codegen_name_util_1 = __webpack_require__(53);
  11036. var codegen_logic_util_1 = __webpack_require__(54);
  11037. var codegen_facade_1 = __webpack_require__(55);
  11038. var constants_1 = __webpack_require__(36);
  11039. var proto_change_detector_1 = __webpack_require__(37);
  11040. /**
  11041. * The code generator takes a list of proto records and creates a function/class
  11042. * that "emulates" what the developer would write by hand to implement the same
  11043. * kind of behaviour.
  11044. *
  11045. * This code should be kept in sync with the Dart transformer's
  11046. * `angular2.transform.template_compiler.change_detector_codegen` library. If you make updates
  11047. * here, please make equivalent changes there.
  11048. */
  11049. var IS_CHANGED_LOCAL = "isChanged";
  11050. var CHANGES_LOCAL = "changes";
  11051. var ChangeDetectorJITGenerator = (function () {
  11052. function ChangeDetectorJITGenerator(definition, changeDetectionUtilVarName, abstractChangeDetectorVarName, changeDetectorStateVarName) {
  11053. this.changeDetectionUtilVarName = changeDetectionUtilVarName;
  11054. this.abstractChangeDetectorVarName = abstractChangeDetectorVarName;
  11055. this.changeDetectorStateVarName = changeDetectorStateVarName;
  11056. var propertyBindingRecords = proto_change_detector_1.createPropertyRecords(definition);
  11057. var eventBindingRecords = proto_change_detector_1.createEventRecords(definition);
  11058. var propertyBindingTargets = definition.bindingRecords.map(function (b) { return b.target; });
  11059. this.id = definition.id;
  11060. this.changeDetectionStrategy = definition.strategy;
  11061. this.genConfig = definition.genConfig;
  11062. this.records = propertyBindingRecords;
  11063. this.propertyBindingTargets = propertyBindingTargets;
  11064. this.eventBindings = eventBindingRecords;
  11065. this.directiveRecords = definition.directiveRecords;
  11066. this._names = new codegen_name_util_1.CodegenNameUtil(this.records, this.eventBindings, this.directiveRecords, this.changeDetectionUtilVarName);
  11067. this._logic =
  11068. new codegen_logic_util_1.CodegenLogicUtil(this._names, this.changeDetectionUtilVarName, this.changeDetectorStateVarName, this.changeDetectionStrategy);
  11069. this.typeName = codegen_name_util_1.sanitizeName("ChangeDetector_" + this.id);
  11070. }
  11071. ChangeDetectorJITGenerator.prototype.generate = function () {
  11072. var factorySource = "\n " + this.generateSource() + "\n return function(dispatcher) {\n return new " + this.typeName + "(dispatcher);\n }\n ";
  11073. return new Function(this.abstractChangeDetectorVarName, this.changeDetectionUtilVarName, this.changeDetectorStateVarName, factorySource)(abstract_change_detector_1.AbstractChangeDetector, change_detection_util_1.ChangeDetectionUtil, constants_1.ChangeDetectorState);
  11074. };
  11075. ChangeDetectorJITGenerator.prototype.generateSource = function () {
  11076. return "\n var " + this.typeName + " = function " + this.typeName + "(dispatcher) {\n " + this.abstractChangeDetectorVarName + ".call(\n this, " + JSON.stringify(this.id) + ", dispatcher, " + this.records.length + ",\n " + this.typeName + ".gen_propertyBindingTargets, " + this.typeName + ".gen_directiveIndices,\n " + codegen_facade_1.codify(this.changeDetectionStrategy) + ");\n this.dehydrateDirectives(false);\n }\n\n " + this.typeName + ".prototype = Object.create(" + this.abstractChangeDetectorVarName + ".prototype);\n\n " + this.typeName + ".prototype.detectChangesInRecordsInternal = function(throwOnChange) {\n " + this._names.genInitLocals() + "\n var " + IS_CHANGED_LOCAL + " = false;\n var " + CHANGES_LOCAL + " = null;\n\n " + this._genAllRecords(this.records) + "\n }\n\n " + this._maybeGenHandleEventInternal() + "\n\n " + this._maybeGenAfterContentLifecycleCallbacks() + "\n\n " + this._maybeGenAfterViewLifecycleCallbacks() + "\n\n " + this._maybeGenHydrateDirectives() + "\n\n " + this._maybeGenDehydrateDirectives() + "\n\n " + this._genPropertyBindingTargets() + "\n\n " + this._genDirectiveIndices() + "\n ";
  11077. };
  11078. /** @internal */
  11079. ChangeDetectorJITGenerator.prototype._genPropertyBindingTargets = function () {
  11080. var targets = this._logic.genPropertyBindingTargets(this.propertyBindingTargets, this.genConfig.genDebugInfo);
  11081. return this.typeName + ".gen_propertyBindingTargets = " + targets + ";";
  11082. };
  11083. /** @internal */
  11084. ChangeDetectorJITGenerator.prototype._genDirectiveIndices = function () {
  11085. var indices = this._logic.genDirectiveIndices(this.directiveRecords);
  11086. return this.typeName + ".gen_directiveIndices = " + indices + ";";
  11087. };
  11088. /** @internal */
  11089. ChangeDetectorJITGenerator.prototype._maybeGenHandleEventInternal = function () {
  11090. var _this = this;
  11091. if (this.eventBindings.length > 0) {
  11092. var handlers = this.eventBindings.map(function (eb) { return _this._genEventBinding(eb); }).join("\n");
  11093. return "\n " + this.typeName + ".prototype.handleEventInternal = function(eventName, elIndex, locals) {\n var " + this._names.getPreventDefaultAccesor() + " = false;\n " + this._names.genInitEventLocals() + "\n " + handlers + "\n return " + this._names.getPreventDefaultAccesor() + ";\n }\n ";
  11094. }
  11095. else {
  11096. return '';
  11097. }
  11098. };
  11099. /** @internal */
  11100. ChangeDetectorJITGenerator.prototype._genEventBinding = function (eb) {
  11101. var _this = this;
  11102. var codes = [];
  11103. this._endOfBlockIdxs = [];
  11104. collection_1.ListWrapper.forEachWithIndex(eb.records, function (r, i) {
  11105. var code;
  11106. if (r.isConditionalSkipRecord()) {
  11107. code = _this._genConditionalSkip(r, _this._names.getEventLocalName(eb, i));
  11108. }
  11109. else if (r.isUnconditionalSkipRecord()) {
  11110. code = _this._genUnconditionalSkip(r);
  11111. }
  11112. else {
  11113. code = _this._genEventBindingEval(eb, r);
  11114. }
  11115. code += _this._genEndOfSkipBlock(i);
  11116. codes.push(code);
  11117. });
  11118. return "\n if (eventName === \"" + eb.eventName + "\" && elIndex === " + eb.elIndex + ") {\n " + codes.join("\n") + "\n }";
  11119. };
  11120. /** @internal */
  11121. ChangeDetectorJITGenerator.prototype._genEventBindingEval = function (eb, r) {
  11122. if (r.lastInBinding) {
  11123. var evalRecord = this._logic.genEventBindingEvalValue(eb, r);
  11124. var markPath = this._genMarkPathToRootAsCheckOnce(r);
  11125. var prevDefault = this._genUpdatePreventDefault(eb, r);
  11126. return evalRecord + "\n" + markPath + "\n" + prevDefault;
  11127. }
  11128. else {
  11129. return this._logic.genEventBindingEvalValue(eb, r);
  11130. }
  11131. };
  11132. /** @internal */
  11133. ChangeDetectorJITGenerator.prototype._genMarkPathToRootAsCheckOnce = function (r) {
  11134. var br = r.bindingRecord;
  11135. if (br.isDefaultChangeDetection()) {
  11136. return "";
  11137. }
  11138. else {
  11139. return this._names.getDetectorName(br.directiveRecord.directiveIndex) + ".markPathToRootAsCheckOnce();";
  11140. }
  11141. };
  11142. /** @internal */
  11143. ChangeDetectorJITGenerator.prototype._genUpdatePreventDefault = function (eb, r) {
  11144. var local = this._names.getEventLocalName(eb, r.selfIndex);
  11145. return "if (" + local + " === false) { " + this._names.getPreventDefaultAccesor() + " = true};";
  11146. };
  11147. /** @internal */
  11148. ChangeDetectorJITGenerator.prototype._maybeGenDehydrateDirectives = function () {
  11149. var destroyPipesCode = this._names.genPipeOnDestroy();
  11150. if (destroyPipesCode) {
  11151. destroyPipesCode = "if (destroyPipes) { " + destroyPipesCode + " }";
  11152. }
  11153. var dehydrateFieldsCode = this._names.genDehydrateFields();
  11154. if (!destroyPipesCode && !dehydrateFieldsCode)
  11155. return '';
  11156. return this.typeName + ".prototype.dehydrateDirectives = function(destroyPipes) {\n " + destroyPipesCode + "\n " + dehydrateFieldsCode + "\n }";
  11157. };
  11158. /** @internal */
  11159. ChangeDetectorJITGenerator.prototype._maybeGenHydrateDirectives = function () {
  11160. var hydrateDirectivesCode = this._logic.genHydrateDirectives(this.directiveRecords);
  11161. var hydrateDetectorsCode = this._logic.genHydrateDetectors(this.directiveRecords);
  11162. if (!hydrateDirectivesCode && !hydrateDetectorsCode)
  11163. return '';
  11164. return this.typeName + ".prototype.hydrateDirectives = function(directives) {\n " + hydrateDirectivesCode + "\n " + hydrateDetectorsCode + "\n }";
  11165. };
  11166. /** @internal */
  11167. ChangeDetectorJITGenerator.prototype._maybeGenAfterContentLifecycleCallbacks = function () {
  11168. var notifications = this._logic.genContentLifecycleCallbacks(this.directiveRecords);
  11169. if (notifications.length > 0) {
  11170. var directiveNotifications = notifications.join("\n");
  11171. return "\n " + this.typeName + ".prototype.afterContentLifecycleCallbacksInternal = function() {\n " + directiveNotifications + "\n }\n ";
  11172. }
  11173. else {
  11174. return '';
  11175. }
  11176. };
  11177. /** @internal */
  11178. ChangeDetectorJITGenerator.prototype._maybeGenAfterViewLifecycleCallbacks = function () {
  11179. var notifications = this._logic.genViewLifecycleCallbacks(this.directiveRecords);
  11180. if (notifications.length > 0) {
  11181. var directiveNotifications = notifications.join("\n");
  11182. return "\n " + this.typeName + ".prototype.afterViewLifecycleCallbacksInternal = function() {\n " + directiveNotifications + "\n }\n ";
  11183. }
  11184. else {
  11185. return '';
  11186. }
  11187. };
  11188. /** @internal */
  11189. ChangeDetectorJITGenerator.prototype._genAllRecords = function (rs) {
  11190. var codes = [];
  11191. this._endOfBlockIdxs = [];
  11192. for (var i = 0; i < rs.length; i++) {
  11193. var code = void 0;
  11194. var r = rs[i];
  11195. if (r.isLifeCycleRecord()) {
  11196. code = this._genDirectiveLifecycle(r);
  11197. }
  11198. else if (r.isPipeRecord()) {
  11199. code = this._genPipeCheck(r);
  11200. }
  11201. else if (r.isConditionalSkipRecord()) {
  11202. code = this._genConditionalSkip(r, this._names.getLocalName(r.contextIndex));
  11203. }
  11204. else if (r.isUnconditionalSkipRecord()) {
  11205. code = this._genUnconditionalSkip(r);
  11206. }
  11207. else {
  11208. code = this._genReferenceCheck(r);
  11209. }
  11210. code = "\n " + this._maybeFirstInBinding(r) + "\n " + code + "\n " + this._maybeGenLastInDirective(r) + "\n " + this._genEndOfSkipBlock(i) + "\n ";
  11211. codes.push(code);
  11212. }
  11213. return codes.join("\n");
  11214. };
  11215. /** @internal */
  11216. ChangeDetectorJITGenerator.prototype._genConditionalSkip = function (r, condition) {
  11217. var maybeNegate = r.mode === proto_record_1.RecordType.SkipRecordsIf ? '!' : '';
  11218. this._endOfBlockIdxs.push(r.fixedArgs[0] - 1);
  11219. return "if (" + maybeNegate + condition + ") {";
  11220. };
  11221. /** @internal */
  11222. ChangeDetectorJITGenerator.prototype._genUnconditionalSkip = function (r) {
  11223. this._endOfBlockIdxs.pop();
  11224. this._endOfBlockIdxs.push(r.fixedArgs[0] - 1);
  11225. return "} else {";
  11226. };
  11227. /** @internal */
  11228. ChangeDetectorJITGenerator.prototype._genEndOfSkipBlock = function (protoIndex) {
  11229. if (!collection_1.ListWrapper.isEmpty(this._endOfBlockIdxs)) {
  11230. var endOfBlock = collection_1.ListWrapper.last(this._endOfBlockIdxs);
  11231. if (protoIndex === endOfBlock) {
  11232. this._endOfBlockIdxs.pop();
  11233. return '}';
  11234. }
  11235. }
  11236. return '';
  11237. };
  11238. /** @internal */
  11239. ChangeDetectorJITGenerator.prototype._genDirectiveLifecycle = function (r) {
  11240. if (r.name === "DoCheck") {
  11241. return this._genOnCheck(r);
  11242. }
  11243. else if (r.name === "OnInit") {
  11244. return this._genOnInit(r);
  11245. }
  11246. else if (r.name === "OnChanges") {
  11247. return this._genOnChange(r);
  11248. }
  11249. else {
  11250. throw new exceptions_1.BaseException("Unknown lifecycle event '" + r.name + "'");
  11251. }
  11252. };
  11253. /** @internal */
  11254. ChangeDetectorJITGenerator.prototype._genPipeCheck = function (r) {
  11255. var _this = this;
  11256. var context = this._names.getLocalName(r.contextIndex);
  11257. var argString = r.args.map(function (arg) { return _this._names.getLocalName(arg); }).join(", ");
  11258. var oldValue = this._names.getFieldName(r.selfIndex);
  11259. var newValue = this._names.getLocalName(r.selfIndex);
  11260. var pipe = this._names.getPipeName(r.selfIndex);
  11261. var pipeName = r.name;
  11262. var init = "\n if (" + pipe + " === " + this.changeDetectionUtilVarName + ".uninitialized) {\n " + pipe + " = " + this._names.getPipesAccessorName() + ".get('" + pipeName + "');\n }\n ";
  11263. var read = newValue + " = " + pipe + ".pipe.transform(" + context + ", [" + argString + "]);";
  11264. var contexOrArgCheck = r.args.map(function (a) { return _this._names.getChangeName(a); });
  11265. contexOrArgCheck.push(this._names.getChangeName(r.contextIndex));
  11266. var condition = "!" + pipe + ".pure || (" + contexOrArgCheck.join(" || ") + ")";
  11267. var check = "\n if (" + this.changeDetectionUtilVarName + ".looseNotIdentical(" + oldValue + ", " + newValue + ")) {\n " + newValue + " = " + this.changeDetectionUtilVarName + ".unwrapValue(" + newValue + ")\n " + this._genChangeMarker(r) + "\n " + this._genUpdateDirectiveOrElement(r) + "\n " + this._genAddToChanges(r) + "\n " + oldValue + " = " + newValue + ";\n }\n ";
  11268. var genCode = r.shouldBeChecked() ? "" + read + check : read;
  11269. if (r.isUsedByOtherRecord()) {
  11270. return init + " if (" + condition + ") { " + genCode + " } else { " + newValue + " = " + oldValue + "; }";
  11271. }
  11272. else {
  11273. return init + " if (" + condition + ") { " + genCode + " }";
  11274. }
  11275. };
  11276. /** @internal */
  11277. ChangeDetectorJITGenerator.prototype._genReferenceCheck = function (r) {
  11278. var _this = this;
  11279. var oldValue = this._names.getFieldName(r.selfIndex);
  11280. var newValue = this._names.getLocalName(r.selfIndex);
  11281. var read = "\n " + this._logic.genPropertyBindingEvalValue(r) + "\n ";
  11282. var check = "\n if (" + this.changeDetectionUtilVarName + ".looseNotIdentical(" + oldValue + ", " + newValue + ")) {\n " + this._genChangeMarker(r) + "\n " + this._genUpdateDirectiveOrElement(r) + "\n " + this._genAddToChanges(r) + "\n " + oldValue + " = " + newValue + ";\n }\n ";
  11283. var genCode = r.shouldBeChecked() ? "" + read + check : read;
  11284. if (r.isPureFunction()) {
  11285. var condition = r.args.map(function (a) { return _this._names.getChangeName(a); }).join(" || ");
  11286. if (r.isUsedByOtherRecord()) {
  11287. return "if (" + condition + ") { " + genCode + " } else { " + newValue + " = " + oldValue + "; }";
  11288. }
  11289. else {
  11290. return "if (" + condition + ") { " + genCode + " }";
  11291. }
  11292. }
  11293. else {
  11294. return genCode;
  11295. }
  11296. };
  11297. /** @internal */
  11298. ChangeDetectorJITGenerator.prototype._genChangeMarker = function (r) {
  11299. return r.argumentToPureFunction ? this._names.getChangeName(r.selfIndex) + " = true" : "";
  11300. };
  11301. /** @internal */
  11302. ChangeDetectorJITGenerator.prototype._genUpdateDirectiveOrElement = function (r) {
  11303. if (!r.lastInBinding)
  11304. return "";
  11305. var newValue = this._names.getLocalName(r.selfIndex);
  11306. var oldValue = this._names.getFieldName(r.selfIndex);
  11307. var notifyDebug = this.genConfig.logBindingUpdate ? "this.logBindingUpdate(" + newValue + ");" : "";
  11308. var br = r.bindingRecord;
  11309. if (br.target.isDirective()) {
  11310. var directiveProperty = this._names.getDirectiveName(br.directiveRecord.directiveIndex) + "." + br.target.name;
  11311. return "\n " + this._genThrowOnChangeCheck(oldValue, newValue) + "\n " + directiveProperty + " = " + newValue + ";\n " + notifyDebug + "\n " + IS_CHANGED_LOCAL + " = true;\n ";
  11312. }
  11313. else {
  11314. return "\n " + this._genThrowOnChangeCheck(oldValue, newValue) + "\n this.notifyDispatcher(" + newValue + ");\n " + notifyDebug + "\n ";
  11315. }
  11316. };
  11317. /** @internal */
  11318. ChangeDetectorJITGenerator.prototype._genThrowOnChangeCheck = function (oldValue, newValue) {
  11319. if (lang_1.assertionsEnabled()) {
  11320. return "\n if(throwOnChange) {\n this.throwOnChangeError(" + oldValue + ", " + newValue + ");\n }\n ";
  11321. }
  11322. else {
  11323. return '';
  11324. }
  11325. };
  11326. /** @internal */
  11327. ChangeDetectorJITGenerator.prototype._genAddToChanges = function (r) {
  11328. var newValue = this._names.getLocalName(r.selfIndex);
  11329. var oldValue = this._names.getFieldName(r.selfIndex);
  11330. if (!r.bindingRecord.callOnChanges())
  11331. return "";
  11332. return CHANGES_LOCAL + " = this.addChange(" + CHANGES_LOCAL + ", " + oldValue + ", " + newValue + ");";
  11333. };
  11334. /** @internal */
  11335. ChangeDetectorJITGenerator.prototype._maybeFirstInBinding = function (r) {
  11336. var prev = change_detection_util_1.ChangeDetectionUtil.protoByIndex(this.records, r.selfIndex - 1);
  11337. var firstInBinding = lang_1.isBlank(prev) || prev.bindingRecord !== r.bindingRecord;
  11338. return firstInBinding && !r.bindingRecord.isDirectiveLifecycle() ?
  11339. this._names.getPropertyBindingIndex() + " = " + r.propertyBindingIndex + ";" :
  11340. '';
  11341. };
  11342. /** @internal */
  11343. ChangeDetectorJITGenerator.prototype._maybeGenLastInDirective = function (r) {
  11344. if (!r.lastInDirective)
  11345. return "";
  11346. return "\n " + CHANGES_LOCAL + " = null;\n " + this._genNotifyOnPushDetectors(r) + "\n " + IS_CHANGED_LOCAL + " = false;\n ";
  11347. };
  11348. /** @internal */
  11349. ChangeDetectorJITGenerator.prototype._genOnCheck = function (r) {
  11350. var br = r.bindingRecord;
  11351. return "if (!throwOnChange) " + this._names.getDirectiveName(br.directiveRecord.directiveIndex) + ".ngDoCheck();";
  11352. };
  11353. /** @internal */
  11354. ChangeDetectorJITGenerator.prototype._genOnInit = function (r) {
  11355. var br = r.bindingRecord;
  11356. return "if (!throwOnChange && " + this._names.getStateName() + " === " + this.changeDetectorStateVarName + ".NeverChecked) " + this._names.getDirectiveName(br.directiveRecord.directiveIndex) + ".ngOnInit();";
  11357. };
  11358. /** @internal */
  11359. ChangeDetectorJITGenerator.prototype._genOnChange = function (r) {
  11360. var br = r.bindingRecord;
  11361. return "if (!throwOnChange && " + CHANGES_LOCAL + ") " + this._names.getDirectiveName(br.directiveRecord.directiveIndex) + ".ngOnChanges(" + CHANGES_LOCAL + ");";
  11362. };
  11363. /** @internal */
  11364. ChangeDetectorJITGenerator.prototype._genNotifyOnPushDetectors = function (r) {
  11365. var br = r.bindingRecord;
  11366. if (!r.lastInDirective || br.isDefaultChangeDetection())
  11367. return "";
  11368. var retVal = "\n if(" + IS_CHANGED_LOCAL + ") {\n " + this._names.getDetectorName(br.directiveRecord.directiveIndex) + ".markAsCheckOnce();\n }\n ";
  11369. return retVal;
  11370. };
  11371. return ChangeDetectorJITGenerator;
  11372. })();
  11373. exports.ChangeDetectorJITGenerator = ChangeDetectorJITGenerator;
  11374. /***/ },
  11375. /* 53 */
  11376. /***/ function(module, exports, __webpack_require__) {
  11377. var lang_1 = __webpack_require__(5);
  11378. var collection_1 = __webpack_require__(12);
  11379. // The names of these fields must be kept in sync with abstract_change_detector.ts or change
  11380. // detection will fail.
  11381. var _STATE_ACCESSOR = "state";
  11382. var _CONTEXT_ACCESSOR = "context";
  11383. var _PROP_BINDING_INDEX = "propertyBindingIndex";
  11384. var _DIRECTIVES_ACCESSOR = "directiveIndices";
  11385. var _DISPATCHER_ACCESSOR = "dispatcher";
  11386. var _LOCALS_ACCESSOR = "locals";
  11387. var _MODE_ACCESSOR = "mode";
  11388. var _PIPES_ACCESSOR = "pipes";
  11389. var _PROTOS_ACCESSOR = "protos";
  11390. exports.CONTEXT_ACCESSOR = "context";
  11391. // `context` is always first.
  11392. exports.CONTEXT_INDEX = 0;
  11393. var _FIELD_PREFIX = 'this.';
  11394. var _whiteSpaceRegExp = /\W/g;
  11395. /**
  11396. * Returns `s` with all non-identifier characters removed.
  11397. */
  11398. function sanitizeName(s) {
  11399. return lang_1.StringWrapper.replaceAll(s, _whiteSpaceRegExp, '');
  11400. }
  11401. exports.sanitizeName = sanitizeName;
  11402. /**
  11403. * Class responsible for providing field and local variable names for change detector classes.
  11404. * Also provides some convenience functions, for example, declaring variables, destroying pipes,
  11405. * and dehydrating the detector.
  11406. */
  11407. var CodegenNameUtil = (function () {
  11408. function CodegenNameUtil(_records, _eventBindings, _directiveRecords, _utilName) {
  11409. this._records = _records;
  11410. this._eventBindings = _eventBindings;
  11411. this._directiveRecords = _directiveRecords;
  11412. this._utilName = _utilName;
  11413. /** @internal */
  11414. this._sanitizedEventNames = new collection_1.Map();
  11415. this._sanitizedNames = collection_1.ListWrapper.createFixedSize(this._records.length + 1);
  11416. this._sanitizedNames[exports.CONTEXT_INDEX] = exports.CONTEXT_ACCESSOR;
  11417. for (var i = 0, iLen = this._records.length; i < iLen; ++i) {
  11418. this._sanitizedNames[i + 1] = sanitizeName("" + this._records[i].name + i);
  11419. }
  11420. for (var ebIndex = 0; ebIndex < _eventBindings.length; ++ebIndex) {
  11421. var eb = _eventBindings[ebIndex];
  11422. var names = [exports.CONTEXT_ACCESSOR];
  11423. for (var i = 0, iLen = eb.records.length; i < iLen; ++i) {
  11424. names.push(sanitizeName("" + eb.records[i].name + i + "_" + ebIndex));
  11425. }
  11426. this._sanitizedEventNames.set(eb, names);
  11427. }
  11428. }
  11429. /** @internal */
  11430. CodegenNameUtil.prototype._addFieldPrefix = function (name) { return "" + _FIELD_PREFIX + name; };
  11431. CodegenNameUtil.prototype.getDispatcherName = function () { return this._addFieldPrefix(_DISPATCHER_ACCESSOR); };
  11432. CodegenNameUtil.prototype.getPipesAccessorName = function () { return this._addFieldPrefix(_PIPES_ACCESSOR); };
  11433. CodegenNameUtil.prototype.getProtosName = function () { return this._addFieldPrefix(_PROTOS_ACCESSOR); };
  11434. CodegenNameUtil.prototype.getDirectivesAccessorName = function () { return this._addFieldPrefix(_DIRECTIVES_ACCESSOR); };
  11435. CodegenNameUtil.prototype.getLocalsAccessorName = function () { return this._addFieldPrefix(_LOCALS_ACCESSOR); };
  11436. CodegenNameUtil.prototype.getStateName = function () { return this._addFieldPrefix(_STATE_ACCESSOR); };
  11437. CodegenNameUtil.prototype.getModeName = function () { return this._addFieldPrefix(_MODE_ACCESSOR); };
  11438. CodegenNameUtil.prototype.getPropertyBindingIndex = function () { return this._addFieldPrefix(_PROP_BINDING_INDEX); };
  11439. CodegenNameUtil.prototype.getLocalName = function (idx) { return "l_" + this._sanitizedNames[idx]; };
  11440. CodegenNameUtil.prototype.getEventLocalName = function (eb, idx) {
  11441. return "l_" + this._sanitizedEventNames.get(eb)[idx];
  11442. };
  11443. CodegenNameUtil.prototype.getChangeName = function (idx) { return "c_" + this._sanitizedNames[idx]; };
  11444. /**
  11445. * Generate a statement initializing local variables used when detecting changes.
  11446. */
  11447. CodegenNameUtil.prototype.genInitLocals = function () {
  11448. var declarations = [];
  11449. var assignments = [];
  11450. for (var i = 0, iLen = this.getFieldCount(); i < iLen; ++i) {
  11451. if (i == exports.CONTEXT_INDEX) {
  11452. declarations.push(this.getLocalName(i) + " = " + this.getFieldName(i));
  11453. }
  11454. else {
  11455. var rec = this._records[i - 1];
  11456. if (rec.argumentToPureFunction) {
  11457. var changeName = this.getChangeName(i);
  11458. declarations.push(this.getLocalName(i) + "," + changeName);
  11459. assignments.push(changeName);
  11460. }
  11461. else {
  11462. declarations.push("" + this.getLocalName(i));
  11463. }
  11464. }
  11465. }
  11466. var assignmentsCode = collection_1.ListWrapper.isEmpty(assignments) ? '' : assignments.join('=') + " = false;";
  11467. return "var " + declarations.join(',') + ";" + assignmentsCode;
  11468. };
  11469. /**
  11470. * Generate a statement initializing local variables for event handlers.
  11471. */
  11472. CodegenNameUtil.prototype.genInitEventLocals = function () {
  11473. var _this = this;
  11474. var res = [(this.getLocalName(exports.CONTEXT_INDEX) + " = " + this.getFieldName(exports.CONTEXT_INDEX))];
  11475. this._sanitizedEventNames.forEach(function (names, eb) {
  11476. for (var i = 0; i < names.length; ++i) {
  11477. if (i !== exports.CONTEXT_INDEX) {
  11478. res.push("" + _this.getEventLocalName(eb, i));
  11479. }
  11480. }
  11481. });
  11482. return res.length > 1 ? "var " + res.join(',') + ";" : '';
  11483. };
  11484. CodegenNameUtil.prototype.getPreventDefaultAccesor = function () { return "preventDefault"; };
  11485. CodegenNameUtil.prototype.getFieldCount = function () { return this._sanitizedNames.length; };
  11486. CodegenNameUtil.prototype.getFieldName = function (idx) { return this._addFieldPrefix(this._sanitizedNames[idx]); };
  11487. CodegenNameUtil.prototype.getAllFieldNames = function () {
  11488. var fieldList = [];
  11489. for (var k = 0, kLen = this.getFieldCount(); k < kLen; ++k) {
  11490. if (k === 0 || this._records[k - 1].shouldBeChecked()) {
  11491. fieldList.push(this.getFieldName(k));
  11492. }
  11493. }
  11494. for (var i = 0, iLen = this._records.length; i < iLen; ++i) {
  11495. var rec = this._records[i];
  11496. if (rec.isPipeRecord()) {
  11497. fieldList.push(this.getPipeName(rec.selfIndex));
  11498. }
  11499. }
  11500. for (var j = 0, jLen = this._directiveRecords.length; j < jLen; ++j) {
  11501. var dRec = this._directiveRecords[j];
  11502. fieldList.push(this.getDirectiveName(dRec.directiveIndex));
  11503. if (!dRec.isDefaultChangeDetection()) {
  11504. fieldList.push(this.getDetectorName(dRec.directiveIndex));
  11505. }
  11506. }
  11507. return fieldList;
  11508. };
  11509. /**
  11510. * Generates statements which clear all fields so that the change detector is dehydrated.
  11511. */
  11512. CodegenNameUtil.prototype.genDehydrateFields = function () {
  11513. var fields = this.getAllFieldNames();
  11514. collection_1.ListWrapper.removeAt(fields, exports.CONTEXT_INDEX);
  11515. if (collection_1.ListWrapper.isEmpty(fields))
  11516. return '';
  11517. // At least one assignment.
  11518. fields.push(this._utilName + ".uninitialized;");
  11519. return fields.join(' = ');
  11520. };
  11521. /**
  11522. * Generates statements destroying all pipe variables.
  11523. */
  11524. CodegenNameUtil.prototype.genPipeOnDestroy = function () {
  11525. var _this = this;
  11526. return this._records.filter(function (r) { return r.isPipeRecord(); })
  11527. .map(function (r) { return (_this._utilName + ".callPipeOnDestroy(" + _this.getPipeName(r.selfIndex) + ");"); })
  11528. .join('\n');
  11529. };
  11530. CodegenNameUtil.prototype.getPipeName = function (idx) {
  11531. return this._addFieldPrefix(this._sanitizedNames[idx] + "_pipe");
  11532. };
  11533. CodegenNameUtil.prototype.getDirectiveName = function (d) {
  11534. return this._addFieldPrefix("directive_" + d.name);
  11535. };
  11536. CodegenNameUtil.prototype.getDetectorName = function (d) { return this._addFieldPrefix("detector_" + d.name); };
  11537. return CodegenNameUtil;
  11538. })();
  11539. exports.CodegenNameUtil = CodegenNameUtil;
  11540. /***/ },
  11541. /* 54 */
  11542. /***/ function(module, exports, __webpack_require__) {
  11543. var lang_1 = __webpack_require__(5);
  11544. var codegen_facade_1 = __webpack_require__(55);
  11545. var proto_record_1 = __webpack_require__(48);
  11546. var constants_1 = __webpack_require__(36);
  11547. var exceptions_1 = __webpack_require__(14);
  11548. /**
  11549. * Class responsible for providing change detection logic for change detector classes.
  11550. */
  11551. var CodegenLogicUtil = (function () {
  11552. function CodegenLogicUtil(_names, _utilName, _changeDetectorStateName, _changeDetection) {
  11553. this._names = _names;
  11554. this._utilName = _utilName;
  11555. this._changeDetectorStateName = _changeDetectorStateName;
  11556. this._changeDetection = _changeDetection;
  11557. }
  11558. /**
  11559. * Generates a statement which updates the local variable representing `protoRec` with the current
  11560. * value of the record. Used by property bindings.
  11561. */
  11562. CodegenLogicUtil.prototype.genPropertyBindingEvalValue = function (protoRec) {
  11563. var _this = this;
  11564. return this._genEvalValue(protoRec, function (idx) { return _this._names.getLocalName(idx); }, this._names.getLocalsAccessorName());
  11565. };
  11566. /**
  11567. * Generates a statement which updates the local variable representing `protoRec` with the current
  11568. * value of the record. Used by event bindings.
  11569. */
  11570. CodegenLogicUtil.prototype.genEventBindingEvalValue = function (eventRecord, protoRec) {
  11571. var _this = this;
  11572. return this._genEvalValue(protoRec, function (idx) { return _this._names.getEventLocalName(eventRecord, idx); }, "locals");
  11573. };
  11574. CodegenLogicUtil.prototype._genEvalValue = function (protoRec, getLocalName, localsAccessor) {
  11575. var context = (protoRec.contextIndex == -1) ?
  11576. this._names.getDirectiveName(protoRec.directiveIndex) :
  11577. getLocalName(protoRec.contextIndex);
  11578. var argString = protoRec.args.map(function (arg) { return getLocalName(arg); }).join(", ");
  11579. var rhs;
  11580. switch (protoRec.mode) {
  11581. case proto_record_1.RecordType.Self:
  11582. rhs = context;
  11583. break;
  11584. case proto_record_1.RecordType.Const:
  11585. rhs = codegen_facade_1.codify(protoRec.funcOrValue);
  11586. break;
  11587. case proto_record_1.RecordType.PropertyRead:
  11588. rhs = this._observe(context + "." + protoRec.name, protoRec);
  11589. break;
  11590. case proto_record_1.RecordType.SafeProperty:
  11591. var read = this._observe(context + "." + protoRec.name, protoRec);
  11592. rhs =
  11593. this._utilName + ".isValueBlank(" + context + ") ? null : " + this._observe(read, protoRec);
  11594. break;
  11595. case proto_record_1.RecordType.PropertyWrite:
  11596. rhs = context + "." + protoRec.name + " = " + getLocalName(protoRec.args[0]);
  11597. break;
  11598. case proto_record_1.RecordType.Local:
  11599. rhs = this._observe(localsAccessor + ".get(" + codegen_facade_1.rawString(protoRec.name) + ")", protoRec);
  11600. break;
  11601. case proto_record_1.RecordType.InvokeMethod:
  11602. rhs = this._observe(context + "." + protoRec.name + "(" + argString + ")", protoRec);
  11603. break;
  11604. case proto_record_1.RecordType.SafeMethodInvoke:
  11605. var invoke = context + "." + protoRec.name + "(" + argString + ")";
  11606. rhs =
  11607. this._utilName + ".isValueBlank(" + context + ") ? null : " + this._observe(invoke, protoRec);
  11608. break;
  11609. case proto_record_1.RecordType.InvokeClosure:
  11610. rhs = context + "(" + argString + ")";
  11611. break;
  11612. case proto_record_1.RecordType.PrimitiveOp:
  11613. rhs = this._utilName + "." + protoRec.name + "(" + argString + ")";
  11614. break;
  11615. case proto_record_1.RecordType.CollectionLiteral:
  11616. rhs = this._utilName + "." + protoRec.name + "(" + argString + ")";
  11617. break;
  11618. case proto_record_1.RecordType.Interpolate:
  11619. rhs = this._genInterpolation(protoRec);
  11620. break;
  11621. case proto_record_1.RecordType.KeyedRead:
  11622. rhs = this._observe(context + "[" + getLocalName(protoRec.args[0]) + "]", protoRec);
  11623. break;
  11624. case proto_record_1.RecordType.KeyedWrite:
  11625. rhs = context + "[" + getLocalName(protoRec.args[0]) + "] = " + getLocalName(protoRec.args[1]);
  11626. break;
  11627. case proto_record_1.RecordType.Chain:
  11628. rhs = 'null';
  11629. break;
  11630. default:
  11631. throw new exceptions_1.BaseException("Unknown operation " + protoRec.mode);
  11632. }
  11633. return getLocalName(protoRec.selfIndex) + " = " + rhs + ";";
  11634. };
  11635. /** @internal */
  11636. CodegenLogicUtil.prototype._observe = function (exp, rec) {
  11637. // This is an experimental feature. Works only in Dart.
  11638. if (this._changeDetection === constants_1.ChangeDetectionStrategy.OnPushObserve) {
  11639. return "this.observeValue(" + exp + ", " + rec.selfIndex + ")";
  11640. }
  11641. else {
  11642. return exp;
  11643. }
  11644. };
  11645. CodegenLogicUtil.prototype.genPropertyBindingTargets = function (propertyBindingTargets, genDebugInfo) {
  11646. var _this = this;
  11647. var bs = propertyBindingTargets.map(function (b) {
  11648. if (lang_1.isBlank(b))
  11649. return "null";
  11650. var debug = genDebugInfo ? codegen_facade_1.codify(b.debug) : "null";
  11651. return _this._utilName + ".bindingTarget(" + codegen_facade_1.codify(b.mode) + ", " + b.elementIndex + ", " + codegen_facade_1.codify(b.name) + ", " + codegen_facade_1.codify(b.unit) + ", " + debug + ")";
  11652. });
  11653. return "[" + bs.join(", ") + "]";
  11654. };
  11655. CodegenLogicUtil.prototype.genDirectiveIndices = function (directiveRecords) {
  11656. var _this = this;
  11657. var bs = directiveRecords.map(function (b) {
  11658. return (_this._utilName + ".directiveIndex(" + b.directiveIndex.elementIndex + ", " + b.directiveIndex.directiveIndex + ")");
  11659. });
  11660. return "[" + bs.join(", ") + "]";
  11661. };
  11662. /** @internal */
  11663. CodegenLogicUtil.prototype._genInterpolation = function (protoRec) {
  11664. var iVals = [];
  11665. for (var i = 0; i < protoRec.args.length; ++i) {
  11666. iVals.push(codegen_facade_1.codify(protoRec.fixedArgs[i]));
  11667. iVals.push(this._utilName + ".s(" + this._names.getLocalName(protoRec.args[i]) + ")");
  11668. }
  11669. iVals.push(codegen_facade_1.codify(protoRec.fixedArgs[protoRec.args.length]));
  11670. return codegen_facade_1.combineGeneratedStrings(iVals);
  11671. };
  11672. CodegenLogicUtil.prototype.genHydrateDirectives = function (directiveRecords) {
  11673. var res = [];
  11674. for (var i = 0; i < directiveRecords.length; ++i) {
  11675. var r = directiveRecords[i];
  11676. res.push(this._names.getDirectiveName(r.directiveIndex) + " = " + this._genReadDirective(i) + ";");
  11677. }
  11678. return res.join("\n");
  11679. };
  11680. CodegenLogicUtil.prototype._genReadDirective = function (index) {
  11681. // This is an experimental feature. Works only in Dart.
  11682. if (this._changeDetection === constants_1.ChangeDetectionStrategy.OnPushObserve) {
  11683. return "this.observeDirective(this.getDirectiveFor(directives, " + index + "), " + index + ")";
  11684. }
  11685. else {
  11686. return "this.getDirectiveFor(directives, " + index + ")";
  11687. }
  11688. };
  11689. CodegenLogicUtil.prototype.genHydrateDetectors = function (directiveRecords) {
  11690. var res = [];
  11691. for (var i = 0; i < directiveRecords.length; ++i) {
  11692. var r = directiveRecords[i];
  11693. if (!r.isDefaultChangeDetection()) {
  11694. res.push(this._names.getDetectorName(r.directiveIndex) + " = this.getDetectorFor(directives, " + i + ");");
  11695. }
  11696. }
  11697. return res.join("\n");
  11698. };
  11699. CodegenLogicUtil.prototype.genContentLifecycleCallbacks = function (directiveRecords) {
  11700. var res = [];
  11701. var eq = lang_1.IS_DART ? '==' : '===';
  11702. // NOTE(kegluneq): Order is important!
  11703. for (var i = directiveRecords.length - 1; i >= 0; --i) {
  11704. var dir = directiveRecords[i];
  11705. if (dir.callAfterContentInit) {
  11706. res.push("if(" + this._names.getStateName() + " " + eq + " " + this._changeDetectorStateName + ".NeverChecked) " + this._names.getDirectiveName(dir.directiveIndex) + ".ngAfterContentInit();");
  11707. }
  11708. if (dir.callAfterContentChecked) {
  11709. res.push(this._names.getDirectiveName(dir.directiveIndex) + ".ngAfterContentChecked();");
  11710. }
  11711. }
  11712. return res;
  11713. };
  11714. CodegenLogicUtil.prototype.genViewLifecycleCallbacks = function (directiveRecords) {
  11715. var res = [];
  11716. var eq = lang_1.IS_DART ? '==' : '===';
  11717. // NOTE(kegluneq): Order is important!
  11718. for (var i = directiveRecords.length - 1; i >= 0; --i) {
  11719. var dir = directiveRecords[i];
  11720. if (dir.callAfterViewInit) {
  11721. res.push("if(" + this._names.getStateName() + " " + eq + " " + this._changeDetectorStateName + ".NeverChecked) " + this._names.getDirectiveName(dir.directiveIndex) + ".ngAfterViewInit();");
  11722. }
  11723. if (dir.callAfterViewChecked) {
  11724. res.push(this._names.getDirectiveName(dir.directiveIndex) + ".ngAfterViewChecked();");
  11725. }
  11726. }
  11727. return res;
  11728. };
  11729. return CodegenLogicUtil;
  11730. })();
  11731. exports.CodegenLogicUtil = CodegenLogicUtil;
  11732. /***/ },
  11733. /* 55 */
  11734. /***/ function(module, exports) {
  11735. /**
  11736. * Converts `funcOrValue` to a string which can be used in generated code.
  11737. */
  11738. function codify(obj) {
  11739. return JSON.stringify(obj);
  11740. }
  11741. exports.codify = codify;
  11742. function rawString(str) {
  11743. return "'" + str + "'";
  11744. }
  11745. exports.rawString = rawString;
  11746. /**
  11747. * Combine the strings of generated code into a single interpolated string.
  11748. * Each element of `vals` is expected to be a string literal or a codegen'd
  11749. * call to a method returning a string.
  11750. */
  11751. function combineGeneratedStrings(vals) {
  11752. return vals.join(' + ');
  11753. }
  11754. exports.combineGeneratedStrings = combineGeneratedStrings;
  11755. /***/ },
  11756. /* 56 */
  11757. /***/ function(module, exports, __webpack_require__) {
  11758. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  11759. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  11760. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  11761. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  11762. return c > 3 && r && Object.defineProperty(target, key, r), r;
  11763. };
  11764. var __metadata = (this && this.__metadata) || function (k, v) {
  11765. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  11766. };
  11767. var lang_1 = __webpack_require__(5);
  11768. /**
  11769. * Defines template and style encapsulation options available for Component's {@link View}.
  11770. *
  11771. * See {@link ViewMetadata#encapsulation}.
  11772. */
  11773. (function (ViewEncapsulation) {
  11774. /**
  11775. * Emulate `Native` scoping of styles by adding an attribute containing surrogate id to the Host
  11776. * Element and pre-processing the style rules provided via
  11777. * {@link ViewMetadata#styles} or {@link ViewMetadata#stylesUrls}, and adding the new Host Element
  11778. * attribute to all selectors.
  11779. *
  11780. * This is the default option.
  11781. */
  11782. ViewEncapsulation[ViewEncapsulation["Emulated"] = 0] = "Emulated";
  11783. /**
  11784. * Use the native encapsulation mechanism of the renderer.
  11785. *
  11786. * For the DOM this means using [Shadow DOM](https://w3c.github.io/webcomponents/spec/shadow/) and
  11787. * creating a ShadowRoot for Component's Host Element.
  11788. */
  11789. ViewEncapsulation[ViewEncapsulation["Native"] = 1] = "Native";
  11790. /**
  11791. * Don't provide any template or style encapsulation.
  11792. */
  11793. ViewEncapsulation[ViewEncapsulation["None"] = 2] = "None";
  11794. })(exports.ViewEncapsulation || (exports.ViewEncapsulation = {}));
  11795. var ViewEncapsulation = exports.ViewEncapsulation;
  11796. exports.VIEW_ENCAPSULATION_VALUES = [ViewEncapsulation.Emulated, ViewEncapsulation.Native, ViewEncapsulation.None];
  11797. /**
  11798. * Metadata properties available for configuring Views.
  11799. *
  11800. * Each Angular component requires a single `@Component` and at least one `@View` annotation. The
  11801. * `@View` annotation specifies the HTML template to use, and lists the directives that are active
  11802. * within the template.
  11803. *
  11804. * When a component is instantiated, the template is loaded into the component's shadow root, and
  11805. * the expressions and statements in the template are evaluated against the component.
  11806. *
  11807. * For details on the `@Component` annotation, see {@link ComponentMetadata}.
  11808. *
  11809. * ### Example
  11810. *
  11811. * ```
  11812. * @Component({
  11813. * selector: 'greet',
  11814. * template: 'Hello {{name}}!',
  11815. * directives: [GreetUser, Bold]
  11816. * })
  11817. * class Greet {
  11818. * name: string;
  11819. *
  11820. * constructor() {
  11821. * this.name = 'World';
  11822. * }
  11823. * }
  11824. * ```
  11825. */
  11826. var ViewMetadata = (function () {
  11827. function ViewMetadata(_a) {
  11828. var _b = _a === void 0 ? {} : _a, templateUrl = _b.templateUrl, template = _b.template, directives = _b.directives, pipes = _b.pipes, encapsulation = _b.encapsulation, styles = _b.styles, styleUrls = _b.styleUrls;
  11829. this.templateUrl = templateUrl;
  11830. this.template = template;
  11831. this.styleUrls = styleUrls;
  11832. this.styles = styles;
  11833. this.directives = directives;
  11834. this.pipes = pipes;
  11835. this.encapsulation = encapsulation;
  11836. }
  11837. ViewMetadata = __decorate([
  11838. lang_1.CONST(),
  11839. __metadata('design:paramtypes', [Object])
  11840. ], ViewMetadata);
  11841. return ViewMetadata;
  11842. })();
  11843. exports.ViewMetadata = ViewMetadata;
  11844. /***/ },
  11845. /* 57 */
  11846. /***/ function(module, exports, __webpack_require__) {
  11847. // Public API for util
  11848. var decorators_1 = __webpack_require__(9);
  11849. exports.Class = decorators_1.Class;
  11850. /***/ },
  11851. /* 58 */
  11852. /***/ function(module, exports, __webpack_require__) {
  11853. var lang_1 = __webpack_require__(5);
  11854. exports.enableProdMode = lang_1.enableProdMode;
  11855. /***/ },
  11856. /* 59 */
  11857. /***/ function(module, exports, __webpack_require__) {
  11858. // Public API for Facade
  11859. var lang_1 = __webpack_require__(5);
  11860. exports.Type = lang_1.Type;
  11861. var async_1 = __webpack_require__(60);
  11862. exports.EventEmitter = async_1.EventEmitter;
  11863. var exceptions_1 = __webpack_require__(14);
  11864. exports.WrappedException = exceptions_1.WrappedException;
  11865. var exception_handler_1 = __webpack_require__(15);
  11866. exports.ExceptionHandler = exception_handler_1.ExceptionHandler;
  11867. /***/ },
  11868. /* 60 */
  11869. /***/ function(module, exports, __webpack_require__) {
  11870. var __extends = (this && this.__extends) || function (d, b) {
  11871. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  11872. function __() { this.constructor = d; }
  11873. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11874. };
  11875. var lang_1 = __webpack_require__(5);
  11876. var promise_1 = __webpack_require__(61);
  11877. exports.PromiseWrapper = promise_1.PromiseWrapper;
  11878. exports.Promise = promise_1.Promise;
  11879. var Subject_1 = __webpack_require__(62);
  11880. var fromPromise_1 = __webpack_require__(63);
  11881. var toPromise_1 = __webpack_require__(64);
  11882. var Observable_1 = __webpack_require__(62);
  11883. exports.Observable = Observable_1.Observable;
  11884. var Subject_2 = __webpack_require__(62);
  11885. exports.Subject = Subject_2.Subject;
  11886. var TimerWrapper = (function () {
  11887. function TimerWrapper() {
  11888. }
  11889. TimerWrapper.setTimeout = function (fn, millis) {
  11890. return lang_1.global.setTimeout(fn, millis);
  11891. };
  11892. TimerWrapper.clearTimeout = function (id) { lang_1.global.clearTimeout(id); };
  11893. TimerWrapper.setInterval = function (fn, millis) {
  11894. return lang_1.global.setInterval(fn, millis);
  11895. };
  11896. TimerWrapper.clearInterval = function (id) { lang_1.global.clearInterval(id); };
  11897. return TimerWrapper;
  11898. })();
  11899. exports.TimerWrapper = TimerWrapper;
  11900. var ObservableWrapper = (function () {
  11901. function ObservableWrapper() {
  11902. }
  11903. // TODO(vsavkin): when we use rxnext, try inferring the generic type from the first arg
  11904. ObservableWrapper.subscribe = function (emitter, onNext, onError, onComplete) {
  11905. if (onComplete === void 0) { onComplete = function () { }; }
  11906. onError = (typeof onError === "function") && onError || lang_1.noop;
  11907. onComplete = (typeof onComplete === "function") && onComplete || lang_1.noop;
  11908. return emitter.subscribe({ next: onNext, error: onError, complete: onComplete });
  11909. };
  11910. ObservableWrapper.isObservable = function (obs) { return !!obs.subscribe; };
  11911. /**
  11912. * Returns whether `obs` has any subscribers listening to events.
  11913. */
  11914. ObservableWrapper.hasSubscribers = function (obs) { return obs.observers.length > 0; };
  11915. ObservableWrapper.dispose = function (subscription) { subscription.unsubscribe(); };
  11916. /**
  11917. * @deprecated - use callEmit() instead
  11918. */
  11919. ObservableWrapper.callNext = function (emitter, value) { emitter.next(value); };
  11920. ObservableWrapper.callEmit = function (emitter, value) { emitter.emit(value); };
  11921. ObservableWrapper.callError = function (emitter, error) { emitter.error(error); };
  11922. ObservableWrapper.callComplete = function (emitter) { emitter.complete(); };
  11923. ObservableWrapper.fromPromise = function (promise) {
  11924. return fromPromise_1.PromiseObservable.create(promise);
  11925. };
  11926. ObservableWrapper.toPromise = function (obj) { return toPromise_1.toPromise.call(obj); };
  11927. return ObservableWrapper;
  11928. })();
  11929. exports.ObservableWrapper = ObservableWrapper;
  11930. /**
  11931. * Use by directives and components to emit custom Events.
  11932. *
  11933. * ### Examples
  11934. *
  11935. * In the following example, `Zippy` alternatively emits `open` and `close` events when its
  11936. * title gets clicked:
  11937. *
  11938. * ```
  11939. * @Component({
  11940. * selector: 'zippy',
  11941. * template: `
  11942. * <div class="zippy">
  11943. * <div (click)="toggle()">Toggle</div>
  11944. * <div [hidden]="!visible">
  11945. * <ng-content></ng-content>
  11946. * </div>
  11947. * </div>`})
  11948. * export class Zippy {
  11949. * visible: boolean = true;
  11950. * @Output() open: EventEmitter<any> = new EventEmitter();
  11951. * @Output() close: EventEmitter<any> = new EventEmitter();
  11952. *
  11953. * toggle() {
  11954. * this.visible = !this.visible;
  11955. * if (this.visible) {
  11956. * this.open.emit(null);
  11957. * } else {
  11958. * this.close.emit(null);
  11959. * }
  11960. * }
  11961. * }
  11962. * ```
  11963. *
  11964. * Use Rx.Observable but provides an adapter to make it work as specified here:
  11965. * https://github.com/jhusain/observable-spec
  11966. *
  11967. * Once a reference implementation of the spec is available, switch to it.
  11968. */
  11969. var EventEmitter = (function (_super) {
  11970. __extends(EventEmitter, _super);
  11971. /**
  11972. * Creates an instance of [EventEmitter], which depending on [isAsync],
  11973. * delivers events synchronously or asynchronously.
  11974. */
  11975. function EventEmitter(isAsync) {
  11976. if (isAsync === void 0) { isAsync = true; }
  11977. _super.call(this);
  11978. this._isAsync = isAsync;
  11979. }
  11980. EventEmitter.prototype.emit = function (value) { _super.prototype.next.call(this, value); };
  11981. /**
  11982. * @deprecated - use .emit(value) instead
  11983. */
  11984. EventEmitter.prototype.next = function (value) { _super.prototype.next.call(this, value); };
  11985. EventEmitter.prototype.subscribe = function (generatorOrNext, error, complete) {
  11986. var schedulerFn;
  11987. var errorFn = function (err) { return null; };
  11988. var completeFn = function () { return null; };
  11989. if (generatorOrNext && typeof generatorOrNext === 'object') {
  11990. schedulerFn = this._isAsync ? function (value) { setTimeout(function () { return generatorOrNext.next(value); }); } :
  11991. function (value) { generatorOrNext.next(value); };
  11992. if (generatorOrNext.error) {
  11993. errorFn = this._isAsync ? function (err) { setTimeout(function () { return generatorOrNext.error(err); }); } :
  11994. function (err) { generatorOrNext.error(err); };
  11995. }
  11996. if (generatorOrNext.complete) {
  11997. completeFn = this._isAsync ? function () { setTimeout(function () { return generatorOrNext.complete(); }); } :
  11998. function () { generatorOrNext.complete(); };
  11999. }
  12000. }
  12001. else {
  12002. schedulerFn = this._isAsync ? function (value) { setTimeout(function () { return generatorOrNext(value); }); } :
  12003. function (value) { generatorOrNext(value); };
  12004. if (error) {
  12005. errorFn =
  12006. this._isAsync ? function (err) { setTimeout(function () { return error(err); }); } : function (err) { error(err); };
  12007. }
  12008. if (complete) {
  12009. completeFn =
  12010. this._isAsync ? function () { setTimeout(function () { return complete(); }); } : function () { complete(); };
  12011. }
  12012. }
  12013. return _super.prototype.subscribe.call(this, schedulerFn, errorFn, completeFn);
  12014. };
  12015. return EventEmitter;
  12016. })(Subject_1.Subject);
  12017. exports.EventEmitter = EventEmitter;
  12018. /***/ },
  12019. /* 61 */
  12020. /***/ function(module, exports) {
  12021. // Promises are put into their own facade file so that they can be used without
  12022. // introducing a dependency on rxjs. They are re-exported through facade/async.
  12023. var PromiseWrapper = (function () {
  12024. function PromiseWrapper() {
  12025. }
  12026. PromiseWrapper.resolve = function (obj) { return Promise.resolve(obj); };
  12027. PromiseWrapper.reject = function (obj, _) { return Promise.reject(obj); };
  12028. // Note: We can't rename this method into `catch`, as this is not a valid
  12029. // method name in Dart.
  12030. PromiseWrapper.catchError = function (promise, onError) {
  12031. return promise.catch(onError);
  12032. };
  12033. PromiseWrapper.all = function (promises) {
  12034. if (promises.length == 0)
  12035. return Promise.resolve([]);
  12036. return Promise.all(promises);
  12037. };
  12038. PromiseWrapper.then = function (promise, success, rejection) {
  12039. return promise.then(success, rejection);
  12040. };
  12041. PromiseWrapper.wrap = function (computation) {
  12042. return new Promise(function (res, rej) {
  12043. try {
  12044. res(computation());
  12045. }
  12046. catch (e) {
  12047. rej(e);
  12048. }
  12049. });
  12050. };
  12051. PromiseWrapper.scheduleMicrotask = function (computation) {
  12052. PromiseWrapper.then(PromiseWrapper.resolve(null), computation, function (_) { });
  12053. };
  12054. PromiseWrapper.isPromise = function (obj) { return obj instanceof Promise; };
  12055. PromiseWrapper.completer = function () {
  12056. var resolve;
  12057. var reject;
  12058. var p = new Promise(function (res, rej) {
  12059. resolve = res;
  12060. reject = rej;
  12061. });
  12062. return { promise: p, resolve: resolve, reject: reject };
  12063. };
  12064. return PromiseWrapper;
  12065. })();
  12066. exports.PromiseWrapper = PromiseWrapper;
  12067. /***/ },
  12068. /* 62 */
  12069. /***/ function(module, exports) {
  12070. module.exports = __WEBPACK_EXTERNAL_MODULE_62__;
  12071. /***/ },
  12072. /* 63 */
  12073. /***/ function(module, exports) {
  12074. module.exports = __WEBPACK_EXTERNAL_MODULE_63__;
  12075. /***/ },
  12076. /* 64 */
  12077. /***/ function(module, exports) {
  12078. module.exports = __WEBPACK_EXTERNAL_MODULE_64__;
  12079. /***/ },
  12080. /* 65 */
  12081. /***/ function(module, exports, __webpack_require__) {
  12082. var __extends = (this && this.__extends) || function (d, b) {
  12083. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  12084. function __() { this.constructor = d; }
  12085. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12086. };
  12087. var ng_zone_1 = __webpack_require__(66);
  12088. var lang_1 = __webpack_require__(5);
  12089. var di_1 = __webpack_require__(6);
  12090. var application_tokens_1 = __webpack_require__(67);
  12091. var async_1 = __webpack_require__(60);
  12092. var collection_1 = __webpack_require__(12);
  12093. var testability_1 = __webpack_require__(68);
  12094. var dynamic_component_loader_1 = __webpack_require__(69);
  12095. var exceptions_1 = __webpack_require__(14);
  12096. var view_ref_1 = __webpack_require__(77);
  12097. var console_1 = __webpack_require__(97);
  12098. var profile_1 = __webpack_require__(45);
  12099. var lang_2 = __webpack_require__(5);
  12100. /**
  12101. * Construct providers specific to an individual root component.
  12102. */
  12103. function _componentProviders(appComponentType) {
  12104. return [
  12105. di_1.provide(application_tokens_1.APP_COMPONENT, { useValue: appComponentType }),
  12106. di_1.provide(application_tokens_1.APP_COMPONENT_REF_PROMISE, {
  12107. useFactory: function (dynamicComponentLoader, appRef, injector) {
  12108. // Save the ComponentRef for disposal later.
  12109. var ref;
  12110. // TODO(rado): investigate whether to support providers on root component.
  12111. return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector, function () { appRef._unloadComponent(ref); })
  12112. .then(function (componentRef) {
  12113. ref = componentRef;
  12114. if (lang_1.isPresent(componentRef.location.nativeElement)) {
  12115. injector.get(testability_1.TestabilityRegistry)
  12116. .registerApplication(componentRef.location.nativeElement, injector.get(testability_1.Testability));
  12117. }
  12118. return componentRef;
  12119. });
  12120. },
  12121. deps: [dynamic_component_loader_1.DynamicComponentLoader, ApplicationRef, di_1.Injector]
  12122. }),
  12123. di_1.provide(appComponentType, {
  12124. useFactory: function (p) { return p.then(function (ref) { return ref.instance; }); },
  12125. deps: [application_tokens_1.APP_COMPONENT_REF_PROMISE]
  12126. }),
  12127. ];
  12128. }
  12129. /**
  12130. * Create an Angular zone.
  12131. */
  12132. function createNgZone() {
  12133. return new ng_zone_1.NgZone({ enableLongStackTrace: lang_1.assertionsEnabled() });
  12134. }
  12135. exports.createNgZone = createNgZone;
  12136. var _platform;
  12137. var _platformProviders;
  12138. /**
  12139. * Initialize the Angular 'platform' on the page.
  12140. *
  12141. * See {@link PlatformRef} for details on the Angular platform.
  12142. *
  12143. * It is also possible to specify providers to be made in the new platform. These providers
  12144. * will be shared between all applications on the page. For example, an abstraction for
  12145. * the browser cookie jar should be bound at the platform level, because there is only one
  12146. * cookie jar regardless of how many applications on the page will be accessing it.
  12147. *
  12148. * The platform function can be called multiple times as long as the same list of providers
  12149. * is passed into each call. If the platform function is called with a different set of
  12150. * provides, Angular will throw an exception.
  12151. */
  12152. function platform(providers) {
  12153. lang_2.lockMode();
  12154. if (lang_1.isPresent(_platform)) {
  12155. if (collection_1.ListWrapper.equals(_platformProviders, providers)) {
  12156. return _platform;
  12157. }
  12158. else {
  12159. throw new exceptions_1.BaseException("platform cannot be initialized with different sets of providers.");
  12160. }
  12161. }
  12162. else {
  12163. return _createPlatform(providers);
  12164. }
  12165. }
  12166. exports.platform = platform;
  12167. /**
  12168. * Dispose the existing platform.
  12169. */
  12170. function disposePlatform() {
  12171. if (lang_1.isPresent(_platform)) {
  12172. _platform.dispose();
  12173. _platform = null;
  12174. }
  12175. }
  12176. exports.disposePlatform = disposePlatform;
  12177. function _createPlatform(providers) {
  12178. _platformProviders = providers;
  12179. var injector = di_1.Injector.resolveAndCreate(providers);
  12180. _platform = new PlatformRef_(injector, function () {
  12181. _platform = null;
  12182. _platformProviders = null;
  12183. });
  12184. _runPlatformInitializers(injector);
  12185. return _platform;
  12186. }
  12187. function _runPlatformInitializers(injector) {
  12188. var inits = injector.getOptional(application_tokens_1.PLATFORM_INITIALIZER);
  12189. if (lang_1.isPresent(inits))
  12190. inits.forEach(function (init) { return init(); });
  12191. }
  12192. /**
  12193. * The Angular platform is the entry point for Angular on a web page. Each page
  12194. * has exactly one platform, and services (such as reflection) which are common
  12195. * to every Angular application running on the page are bound in its scope.
  12196. *
  12197. * A page's platform is initialized implicitly when {@link bootstrap}() is called, or
  12198. * explicitly by calling {@link platform}().
  12199. */
  12200. var PlatformRef = (function () {
  12201. function PlatformRef() {
  12202. }
  12203. Object.defineProperty(PlatformRef.prototype, "injector", {
  12204. /**
  12205. * Retrieve the platform {@link Injector}, which is the parent injector for
  12206. * every Angular application on the page and provides singleton providers.
  12207. */
  12208. get: function () { return exceptions_1.unimplemented(); },
  12209. enumerable: true,
  12210. configurable: true
  12211. });
  12212. ;
  12213. return PlatformRef;
  12214. })();
  12215. exports.PlatformRef = PlatformRef;
  12216. var PlatformRef_ = (function (_super) {
  12217. __extends(PlatformRef_, _super);
  12218. function PlatformRef_(_injector, _dispose) {
  12219. _super.call(this);
  12220. this._injector = _injector;
  12221. this._dispose = _dispose;
  12222. /** @internal */
  12223. this._applications = [];
  12224. /** @internal */
  12225. this._disposeListeners = [];
  12226. }
  12227. PlatformRef_.prototype.registerDisposeListener = function (dispose) { this._disposeListeners.push(dispose); };
  12228. Object.defineProperty(PlatformRef_.prototype, "injector", {
  12229. get: function () { return this._injector; },
  12230. enumerable: true,
  12231. configurable: true
  12232. });
  12233. PlatformRef_.prototype.application = function (providers) {
  12234. var app = this._initApp(createNgZone(), providers);
  12235. return app;
  12236. };
  12237. PlatformRef_.prototype.asyncApplication = function (bindingFn, additionalProviders) {
  12238. var _this = this;
  12239. var zone = createNgZone();
  12240. var completer = async_1.PromiseWrapper.completer();
  12241. zone.run(function () {
  12242. async_1.PromiseWrapper.then(bindingFn(zone), function (providers) {
  12243. if (lang_1.isPresent(additionalProviders)) {
  12244. providers = collection_1.ListWrapper.concat(providers, additionalProviders);
  12245. }
  12246. completer.resolve(_this._initApp(zone, providers));
  12247. });
  12248. });
  12249. return completer.promise;
  12250. };
  12251. PlatformRef_.prototype._initApp = function (zone, providers) {
  12252. var _this = this;
  12253. var injector;
  12254. var app;
  12255. zone.run(function () {
  12256. providers = collection_1.ListWrapper.concat(providers, [
  12257. di_1.provide(ng_zone_1.NgZone, { useValue: zone }),
  12258. di_1.provide(ApplicationRef, { useFactory: function () { return app; }, deps: [] })
  12259. ]);
  12260. var exceptionHandler;
  12261. try {
  12262. injector = _this.injector.resolveAndCreateChild(providers);
  12263. exceptionHandler = injector.get(exceptions_1.ExceptionHandler);
  12264. zone.overrideOnErrorHandler(function (e, s) { return exceptionHandler.call(e, s); });
  12265. }
  12266. catch (e) {
  12267. if (lang_1.isPresent(exceptionHandler)) {
  12268. exceptionHandler.call(e, e.stack);
  12269. }
  12270. else {
  12271. lang_1.print(e.toString());
  12272. }
  12273. }
  12274. });
  12275. app = new ApplicationRef_(this, zone, injector);
  12276. this._applications.push(app);
  12277. _runAppInitializers(injector);
  12278. return app;
  12279. };
  12280. PlatformRef_.prototype.dispose = function () {
  12281. collection_1.ListWrapper.clone(this._applications).forEach(function (app) { return app.dispose(); });
  12282. this._disposeListeners.forEach(function (dispose) { return dispose(); });
  12283. this._dispose();
  12284. };
  12285. /** @internal */
  12286. PlatformRef_.prototype._applicationDisposed = function (app) { collection_1.ListWrapper.remove(this._applications, app); };
  12287. return PlatformRef_;
  12288. })(PlatformRef);
  12289. exports.PlatformRef_ = PlatformRef_;
  12290. function _runAppInitializers(injector) {
  12291. var inits = injector.getOptional(application_tokens_1.APP_INITIALIZER);
  12292. if (lang_1.isPresent(inits))
  12293. inits.forEach(function (init) { return init(); });
  12294. }
  12295. /**
  12296. * A reference to an Angular application running on a page.
  12297. *
  12298. * For more about Angular applications, see the documentation for {@link bootstrap}.
  12299. */
  12300. var ApplicationRef = (function () {
  12301. function ApplicationRef() {
  12302. }
  12303. Object.defineProperty(ApplicationRef.prototype, "injector", {
  12304. /**
  12305. * Retrieve the application {@link Injector}.
  12306. */
  12307. get: function () { return exceptions_1.unimplemented(); },
  12308. enumerable: true,
  12309. configurable: true
  12310. });
  12311. ;
  12312. Object.defineProperty(ApplicationRef.prototype, "zone", {
  12313. /**
  12314. * Retrieve the application {@link NgZone}.
  12315. */
  12316. get: function () { return exceptions_1.unimplemented(); },
  12317. enumerable: true,
  12318. configurable: true
  12319. });
  12320. ;
  12321. Object.defineProperty(ApplicationRef.prototype, "componentTypes", {
  12322. /**
  12323. * Get a list of component types registered to this application.
  12324. */
  12325. get: function () { return exceptions_1.unimplemented(); },
  12326. enumerable: true,
  12327. configurable: true
  12328. });
  12329. ;
  12330. return ApplicationRef;
  12331. })();
  12332. exports.ApplicationRef = ApplicationRef;
  12333. var ApplicationRef_ = (function (_super) {
  12334. __extends(ApplicationRef_, _super);
  12335. function ApplicationRef_(_platform, _zone, _injector) {
  12336. var _this = this;
  12337. _super.call(this);
  12338. this._platform = _platform;
  12339. this._zone = _zone;
  12340. this._injector = _injector;
  12341. /** @internal */
  12342. this._bootstrapListeners = [];
  12343. /** @internal */
  12344. this._disposeListeners = [];
  12345. /** @internal */
  12346. this._rootComponents = [];
  12347. /** @internal */
  12348. this._rootComponentTypes = [];
  12349. /** @internal */
  12350. this._changeDetectorRefs = [];
  12351. /** @internal */
  12352. this._runningTick = false;
  12353. /** @internal */
  12354. this._enforceNoNewChanges = false;
  12355. if (lang_1.isPresent(this._zone)) {
  12356. async_1.ObservableWrapper.subscribe(this._zone.onTurnDone, function (_) { _this._zone.run(function () { _this.tick(); }); });
  12357. }
  12358. this._enforceNoNewChanges = lang_1.assertionsEnabled();
  12359. }
  12360. ApplicationRef_.prototype.registerBootstrapListener = function (listener) {
  12361. this._bootstrapListeners.push(listener);
  12362. };
  12363. ApplicationRef_.prototype.registerDisposeListener = function (dispose) { this._disposeListeners.push(dispose); };
  12364. ApplicationRef_.prototype.registerChangeDetector = function (changeDetector) {
  12365. this._changeDetectorRefs.push(changeDetector);
  12366. };
  12367. ApplicationRef_.prototype.unregisterChangeDetector = function (changeDetector) {
  12368. collection_1.ListWrapper.remove(this._changeDetectorRefs, changeDetector);
  12369. };
  12370. ApplicationRef_.prototype.bootstrap = function (componentType, providers) {
  12371. var _this = this;
  12372. var completer = async_1.PromiseWrapper.completer();
  12373. this._zone.run(function () {
  12374. var componentProviders = _componentProviders(componentType);
  12375. if (lang_1.isPresent(providers)) {
  12376. componentProviders.push(providers);
  12377. }
  12378. var exceptionHandler = _this._injector.get(exceptions_1.ExceptionHandler);
  12379. _this._rootComponentTypes.push(componentType);
  12380. try {
  12381. var injector = _this._injector.resolveAndCreateChild(componentProviders);
  12382. var compRefToken = injector.get(application_tokens_1.APP_COMPONENT_REF_PROMISE);
  12383. var tick = function (componentRef) {
  12384. _this._loadComponent(componentRef);
  12385. completer.resolve(componentRef);
  12386. };
  12387. var tickResult = async_1.PromiseWrapper.then(compRefToken, tick);
  12388. // THIS MUST ONLY RUN IN DART.
  12389. // This is required to report an error when no components with a matching selector found.
  12390. // Otherwise the promise will never be completed.
  12391. // Doing this in JS causes an extra error message to appear.
  12392. if (lang_1.IS_DART) {
  12393. async_1.PromiseWrapper.then(tickResult, function (_) { });
  12394. }
  12395. async_1.PromiseWrapper.then(tickResult, null, function (err, stackTrace) { return completer.reject(err, stackTrace); });
  12396. }
  12397. catch (e) {
  12398. exceptionHandler.call(e, e.stack);
  12399. completer.reject(e, e.stack);
  12400. }
  12401. });
  12402. return completer.promise.then(function (_) {
  12403. var c = _this._injector.get(console_1.Console);
  12404. var modeDescription = lang_1.assertionsEnabled() ?
  12405. "in the development mode. Call enableProdMode() to enable the production mode." :
  12406. "in the production mode. Call enableDevMode() to enable the development mode.";
  12407. c.log("Angular 2 is running " + modeDescription);
  12408. return _;
  12409. });
  12410. };
  12411. /** @internal */
  12412. ApplicationRef_.prototype._loadComponent = function (ref) {
  12413. var appChangeDetector = view_ref_1.internalView(ref.hostView).changeDetector;
  12414. this._changeDetectorRefs.push(appChangeDetector.ref);
  12415. this.tick();
  12416. this._rootComponents.push(ref);
  12417. this._bootstrapListeners.forEach(function (listener) { return listener(ref); });
  12418. };
  12419. /** @internal */
  12420. ApplicationRef_.prototype._unloadComponent = function (ref) {
  12421. if (!collection_1.ListWrapper.contains(this._rootComponents, ref)) {
  12422. return;
  12423. }
  12424. this.unregisterChangeDetector(view_ref_1.internalView(ref.hostView).changeDetector.ref);
  12425. collection_1.ListWrapper.remove(this._rootComponents, ref);
  12426. };
  12427. Object.defineProperty(ApplicationRef_.prototype, "injector", {
  12428. get: function () { return this._injector; },
  12429. enumerable: true,
  12430. configurable: true
  12431. });
  12432. Object.defineProperty(ApplicationRef_.prototype, "zone", {
  12433. get: function () { return this._zone; },
  12434. enumerable: true,
  12435. configurable: true
  12436. });
  12437. ApplicationRef_.prototype.tick = function () {
  12438. if (this._runningTick) {
  12439. throw new exceptions_1.BaseException("ApplicationRef.tick is called recursively");
  12440. }
  12441. var s = ApplicationRef_._tickScope();
  12442. try {
  12443. this._runningTick = true;
  12444. this._changeDetectorRefs.forEach(function (detector) { return detector.detectChanges(); });
  12445. if (this._enforceNoNewChanges) {
  12446. this._changeDetectorRefs.forEach(function (detector) { return detector.checkNoChanges(); });
  12447. }
  12448. }
  12449. finally {
  12450. this._runningTick = false;
  12451. profile_1.wtfLeave(s);
  12452. }
  12453. };
  12454. ApplicationRef_.prototype.dispose = function () {
  12455. // TODO(alxhub): Dispose of the NgZone.
  12456. collection_1.ListWrapper.clone(this._rootComponents).forEach(function (ref) { return ref.dispose(); });
  12457. this._disposeListeners.forEach(function (dispose) { return dispose(); });
  12458. this._platform._applicationDisposed(this);
  12459. };
  12460. Object.defineProperty(ApplicationRef_.prototype, "componentTypes", {
  12461. get: function () { return this._rootComponentTypes; },
  12462. enumerable: true,
  12463. configurable: true
  12464. });
  12465. /** @internal */
  12466. ApplicationRef_._tickScope = profile_1.wtfCreateScope('ApplicationRef#tick()');
  12467. return ApplicationRef_;
  12468. })(ApplicationRef);
  12469. exports.ApplicationRef_ = ApplicationRef_;
  12470. /***/ },
  12471. /* 66 */
  12472. /***/ function(module, exports, __webpack_require__) {
  12473. var collection_1 = __webpack_require__(12);
  12474. var lang_1 = __webpack_require__(5);
  12475. var async_1 = __webpack_require__(60);
  12476. var profile_1 = __webpack_require__(45);
  12477. /**
  12478. * Stores error information; delivered via [NgZone.onError] stream.
  12479. */
  12480. var NgZoneError = (function () {
  12481. function NgZoneError(error, stackTrace) {
  12482. this.error = error;
  12483. this.stackTrace = stackTrace;
  12484. }
  12485. return NgZoneError;
  12486. })();
  12487. exports.NgZoneError = NgZoneError;
  12488. /**
  12489. * An injectable service for executing work inside or outside of the Angular zone.
  12490. *
  12491. * The most common use of this service is to optimize performance when starting a work consisting of
  12492. * one or more asynchronous tasks that don't require UI updates or error handling to be handled by
  12493. * Angular. Such tasks can be kicked off via {@link #runOutsideAngular} and if needed, these tasks
  12494. * can reenter the Angular zone via {@link #run}.
  12495. *
  12496. * <!-- TODO: add/fix links to:
  12497. * - docs explaining zones and the use of zones in Angular and change-detection
  12498. * - link to runOutsideAngular/run (throughout this file!)
  12499. * -->
  12500. *
  12501. * ### Example ([live demo](http://plnkr.co/edit/lY9m8HLy7z06vDoUaSN2?p=preview))
  12502. * ```
  12503. * import {Component, View, NgZone} from 'angular2/core';
  12504. * import {NgIf} from 'angular2/common';
  12505. *
  12506. * @Component({
  12507. * selector: 'ng-zone-demo'.
  12508. * template: `
  12509. * <h2>Demo: NgZone</h2>
  12510. *
  12511. * <p>Progress: {{progress}}%</p>
  12512. * <p *ngIf="progress >= 100">Done processing {{label}} of Angular zone!</p>
  12513. *
  12514. * <button (click)="processWithinAngularZone()">Process within Angular zone</button>
  12515. * <button (click)="processOutsideOfAngularZone()">Process outside of Angular zone</button>
  12516. * `,
  12517. * directives: [NgIf]
  12518. * })
  12519. * export class NgZoneDemo {
  12520. * progress: number = 0;
  12521. * label: string;
  12522. *
  12523. * constructor(private _ngZone: NgZone) {}
  12524. *
  12525. * // Loop inside the Angular zone
  12526. * // so the UI DOES refresh after each setTimeout cycle
  12527. * processWithinAngularZone() {
  12528. * this.label = 'inside';
  12529. * this.progress = 0;
  12530. * this._increaseProgress(() => console.log('Inside Done!'));
  12531. * }
  12532. *
  12533. * // Loop outside of the Angular zone
  12534. * // so the UI DOES NOT refresh after each setTimeout cycle
  12535. * processOutsideOfAngularZone() {
  12536. * this.label = 'outside';
  12537. * this.progress = 0;
  12538. * this._ngZone.runOutsideAngular(() => {
  12539. * this._increaseProgress(() => {
  12540. * // reenter the Angular zone and display done
  12541. * this._ngZone.run(() => {console.log('Outside Done!') });
  12542. * }}));
  12543. * }
  12544. *
  12545. *
  12546. * _increaseProgress(doneCallback: () => void) {
  12547. * this.progress += 1;
  12548. * console.log(`Current progress: ${this.progress}%`);
  12549. *
  12550. * if (this.progress < 100) {
  12551. * window.setTimeout(() => this._increaseProgress(doneCallback)), 10)
  12552. * } else {
  12553. * doneCallback();
  12554. * }
  12555. * }
  12556. * }
  12557. * ```
  12558. */
  12559. var NgZone = (function () {
  12560. /**
  12561. * @param {bool} enableLongStackTrace whether to enable long stack trace. They should only be
  12562. * enabled in development mode as they significantly impact perf.
  12563. */
  12564. function NgZone(_a) {
  12565. var enableLongStackTrace = _a.enableLongStackTrace;
  12566. /** @internal */
  12567. this._runScope = profile_1.wtfCreateScope("NgZone#run()");
  12568. /** @internal */
  12569. this._microtaskScope = profile_1.wtfCreateScope("NgZone#microtask()");
  12570. // Number of microtasks pending from _innerZone (& descendants)
  12571. /** @internal */
  12572. this._pendingMicrotasks = 0;
  12573. // Whether some code has been executed in the _innerZone (& descendants) in the current turn
  12574. /** @internal */
  12575. this._hasExecutedCodeInInnerZone = false;
  12576. // run() call depth in _mountZone. 0 at the end of a macrotask
  12577. // zone.run(() => { // top-level call
  12578. // zone.run(() => {}); // nested call -> in-turn
  12579. // });
  12580. /** @internal */
  12581. this._nestedRun = 0;
  12582. /** @internal */
  12583. this._inVmTurnDone = false;
  12584. /** @internal */
  12585. this._pendingTimeouts = [];
  12586. if (lang_1.global.zone) {
  12587. this._disabled = false;
  12588. this._mountZone = lang_1.global.zone;
  12589. this._innerZone = this._createInnerZone(this._mountZone, enableLongStackTrace);
  12590. }
  12591. else {
  12592. this._disabled = true;
  12593. this._mountZone = null;
  12594. }
  12595. this._onTurnStartEvents = new async_1.EventEmitter(false);
  12596. this._onTurnDoneEvents = new async_1.EventEmitter(false);
  12597. this._onEventDoneEvents = new async_1.EventEmitter(false);
  12598. this._onErrorEvents = new async_1.EventEmitter(false);
  12599. }
  12600. /**
  12601. * Sets the zone hook that is called just before a browser task that is handled by Angular
  12602. * executes.
  12603. *
  12604. * The hook is called once per browser task that is handled by Angular.
  12605. *
  12606. * Setting the hook overrides any previously set hook.
  12607. *
  12608. * @deprecated this API will be removed in the future. Use `onTurnStart` instead.
  12609. */
  12610. NgZone.prototype.overrideOnTurnStart = function (onTurnStartHook) {
  12611. this._onTurnStart = lang_1.normalizeBlank(onTurnStartHook);
  12612. };
  12613. Object.defineProperty(NgZone.prototype, "onTurnStart", {
  12614. /**
  12615. * Notifies subscribers just before Angular event turn starts.
  12616. *
  12617. * Emits an event once per browser task that is handled by Angular.
  12618. */
  12619. get: function () { return this._onTurnStartEvents; },
  12620. enumerable: true,
  12621. configurable: true
  12622. });
  12623. /** @internal */
  12624. NgZone.prototype._notifyOnTurnStart = function (parentRun) {
  12625. var _this = this;
  12626. parentRun.call(this._innerZone, function () { _this._onTurnStartEvents.emit(null); });
  12627. };
  12628. /**
  12629. * Sets the zone hook that is called immediately after Angular zone is done processing the current
  12630. * task and any microtasks scheduled from that task.
  12631. *
  12632. * This is where we typically do change-detection.
  12633. *
  12634. * The hook is called once per browser task that is handled by Angular.
  12635. *
  12636. * Setting the hook overrides any previously set hook.
  12637. *
  12638. * @deprecated this API will be removed in the future. Use `onTurnDone` instead.
  12639. */
  12640. NgZone.prototype.overrideOnTurnDone = function (onTurnDoneHook) {
  12641. this._onTurnDone = lang_1.normalizeBlank(onTurnDoneHook);
  12642. };
  12643. Object.defineProperty(NgZone.prototype, "onTurnDone", {
  12644. /**
  12645. * Notifies subscribers immediately after Angular zone is done processing
  12646. * the current turn and any microtasks scheduled from that turn.
  12647. *
  12648. * Used by Angular as a signal to kick off change-detection.
  12649. */
  12650. get: function () { return this._onTurnDoneEvents; },
  12651. enumerable: true,
  12652. configurable: true
  12653. });
  12654. /** @internal */
  12655. NgZone.prototype._notifyOnTurnDone = function (parentRun) {
  12656. var _this = this;
  12657. parentRun.call(this._innerZone, function () { _this._onTurnDoneEvents.emit(null); });
  12658. };
  12659. /**
  12660. * Sets the zone hook that is called immediately after the `onTurnDone` callback is called and any
  12661. * microstasks scheduled from within that callback are drained.
  12662. *
  12663. * `onEventDoneFn` is executed outside Angular zone, which means that we will no longer attempt to
  12664. * sync the UI with any model changes that occur within this callback.
  12665. *
  12666. * This hook is useful for validating application state (e.g. in a test).
  12667. *
  12668. * Setting the hook overrides any previously set hook.
  12669. *
  12670. * @deprecated this API will be removed in the future. Use `onEventDone` instead.
  12671. */
  12672. NgZone.prototype.overrideOnEventDone = function (onEventDoneFn, opt_waitForAsync) {
  12673. var _this = this;
  12674. if (opt_waitForAsync === void 0) { opt_waitForAsync = false; }
  12675. var normalizedOnEventDone = lang_1.normalizeBlank(onEventDoneFn);
  12676. if (opt_waitForAsync) {
  12677. this._onEventDone = function () {
  12678. if (!_this._pendingTimeouts.length) {
  12679. normalizedOnEventDone();
  12680. }
  12681. };
  12682. }
  12683. else {
  12684. this._onEventDone = normalizedOnEventDone;
  12685. }
  12686. };
  12687. Object.defineProperty(NgZone.prototype, "onEventDone", {
  12688. /**
  12689. * Notifies subscribers immediately after the final `onTurnDone` callback
  12690. * before ending VM event.
  12691. *
  12692. * This event is useful for validating application state (e.g. in a test).
  12693. */
  12694. get: function () { return this._onEventDoneEvents; },
  12695. enumerable: true,
  12696. configurable: true
  12697. });
  12698. /** @internal */
  12699. NgZone.prototype._notifyOnEventDone = function () {
  12700. var _this = this;
  12701. this.runOutsideAngular(function () { _this._onEventDoneEvents.emit(null); });
  12702. };
  12703. Object.defineProperty(NgZone.prototype, "hasPendingMicrotasks", {
  12704. /**
  12705. * Whether there are any outstanding microtasks.
  12706. */
  12707. get: function () { return this._pendingMicrotasks > 0; },
  12708. enumerable: true,
  12709. configurable: true
  12710. });
  12711. Object.defineProperty(NgZone.prototype, "hasPendingTimers", {
  12712. /**
  12713. * Whether there are any outstanding timers.
  12714. */
  12715. get: function () { return this._pendingTimeouts.length > 0; },
  12716. enumerable: true,
  12717. configurable: true
  12718. });
  12719. Object.defineProperty(NgZone.prototype, "hasPendingAsyncTasks", {
  12720. /**
  12721. * Whether there are any outstanding asychnronous tasks of any kind that are
  12722. * scheduled to run within Angular zone.
  12723. *
  12724. * Useful as a signal of UI stability. For example, when a test reaches a
  12725. * point when [hasPendingAsyncTasks] is `false` it might be a good time to run
  12726. * test expectations.
  12727. */
  12728. get: function () { return this.hasPendingMicrotasks || this.hasPendingTimers; },
  12729. enumerable: true,
  12730. configurable: true
  12731. });
  12732. /**
  12733. * Sets the zone hook that is called when an error is thrown in the Angular zone.
  12734. *
  12735. * Setting the hook overrides any previously set hook.
  12736. *
  12737. * @deprecated this API will be removed in the future. Use `onError` instead.
  12738. */
  12739. NgZone.prototype.overrideOnErrorHandler = function (errorHandler) {
  12740. this._onErrorHandler = lang_1.normalizeBlank(errorHandler);
  12741. };
  12742. Object.defineProperty(NgZone.prototype, "onError", {
  12743. get: function () { return this._onErrorEvents; },
  12744. enumerable: true,
  12745. configurable: true
  12746. });
  12747. /**
  12748. * Executes the `fn` function synchronously within the Angular zone and returns value returned by
  12749. * the function.
  12750. *
  12751. * Running functions via `run` allows you to reenter Angular zone from a task that was executed
  12752. * outside of the Angular zone (typically started via {@link #runOutsideAngular}).
  12753. *
  12754. * Any future tasks or microtasks scheduled from within this function will continue executing from
  12755. * within the Angular zone.
  12756. */
  12757. NgZone.prototype.run = function (fn) {
  12758. if (this._disabled) {
  12759. return fn();
  12760. }
  12761. else {
  12762. var s = this._runScope();
  12763. try {
  12764. return this._innerZone.run(fn);
  12765. }
  12766. finally {
  12767. profile_1.wtfLeave(s);
  12768. }
  12769. }
  12770. };
  12771. /**
  12772. * Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
  12773. * the function.
  12774. *
  12775. * Running functions via `runOutsideAngular` allows you to escape Angular's zone and do work that
  12776. * doesn't trigger Angular change-detection or is subject to Angular's error handling.
  12777. *
  12778. * Any future tasks or microtasks scheduled from within this function will continue executing from
  12779. * outside of the Angular zone.
  12780. *
  12781. * Use {@link #run} to reenter the Angular zone and do work that updates the application model.
  12782. */
  12783. NgZone.prototype.runOutsideAngular = function (fn) {
  12784. if (this._disabled) {
  12785. return fn();
  12786. }
  12787. else {
  12788. return this._mountZone.run(fn);
  12789. }
  12790. };
  12791. /** @internal */
  12792. NgZone.prototype._createInnerZone = function (zone, enableLongStackTrace) {
  12793. var microtaskScope = this._microtaskScope;
  12794. var ngZone = this;
  12795. var errorHandling;
  12796. if (enableLongStackTrace) {
  12797. errorHandling = collection_1.StringMapWrapper.merge(Zone.longStackTraceZone, { onError: function (e) { ngZone._notifyOnError(this, e); } });
  12798. }
  12799. else {
  12800. errorHandling = { onError: function (e) { ngZone._notifyOnError(this, e); } };
  12801. }
  12802. return zone.fork(errorHandling)
  12803. .fork({
  12804. '$run': function (parentRun) {
  12805. return function () {
  12806. try {
  12807. ngZone._nestedRun++;
  12808. if (!ngZone._hasExecutedCodeInInnerZone) {
  12809. ngZone._hasExecutedCodeInInnerZone = true;
  12810. ngZone._notifyOnTurnStart(parentRun);
  12811. if (ngZone._onTurnStart) {
  12812. parentRun.call(ngZone._innerZone, ngZone._onTurnStart);
  12813. }
  12814. }
  12815. return parentRun.apply(this, arguments);
  12816. }
  12817. finally {
  12818. ngZone._nestedRun--;
  12819. // If there are no more pending microtasks, we are at the end of a VM turn (or in
  12820. // onTurnStart)
  12821. // _nestedRun will be 0 at the end of a macrotasks (it could be > 0 when there are
  12822. // nested calls
  12823. // to run()).
  12824. if (ngZone._pendingMicrotasks == 0 && ngZone._nestedRun == 0 &&
  12825. !this._inVmTurnDone) {
  12826. if (ngZone._hasExecutedCodeInInnerZone) {
  12827. try {
  12828. this._inVmTurnDone = true;
  12829. ngZone._notifyOnTurnDone(parentRun);
  12830. if (ngZone._onTurnDone) {
  12831. parentRun.call(ngZone._innerZone, ngZone._onTurnDone);
  12832. }
  12833. }
  12834. finally {
  12835. this._inVmTurnDone = false;
  12836. ngZone._hasExecutedCodeInInnerZone = false;
  12837. }
  12838. }
  12839. if (ngZone._pendingMicrotasks === 0) {
  12840. ngZone._notifyOnEventDone();
  12841. if (lang_1.isPresent(ngZone._onEventDone)) {
  12842. ngZone.runOutsideAngular(ngZone._onEventDone);
  12843. }
  12844. }
  12845. }
  12846. }
  12847. };
  12848. },
  12849. '$scheduleMicrotask': function (parentScheduleMicrotask) {
  12850. return function (fn) {
  12851. ngZone._pendingMicrotasks++;
  12852. var microtask = function () {
  12853. var s = microtaskScope();
  12854. try {
  12855. fn();
  12856. }
  12857. finally {
  12858. ngZone._pendingMicrotasks--;
  12859. profile_1.wtfLeave(s);
  12860. }
  12861. };
  12862. parentScheduleMicrotask.call(this, microtask);
  12863. };
  12864. },
  12865. '$setTimeout': function (parentSetTimeout) {
  12866. return function (fn, delay) {
  12867. var args = [];
  12868. for (var _i = 2; _i < arguments.length; _i++) {
  12869. args[_i - 2] = arguments[_i];
  12870. }
  12871. var id;
  12872. var cb = function () {
  12873. fn();
  12874. collection_1.ListWrapper.remove(ngZone._pendingTimeouts, id);
  12875. };
  12876. id = parentSetTimeout(cb, delay, args);
  12877. ngZone._pendingTimeouts.push(id);
  12878. return id;
  12879. };
  12880. },
  12881. '$clearTimeout': function (parentClearTimeout) {
  12882. return function (id) {
  12883. parentClearTimeout(id);
  12884. collection_1.ListWrapper.remove(ngZone._pendingTimeouts, id);
  12885. };
  12886. },
  12887. _innerZone: true
  12888. });
  12889. };
  12890. /** @internal */
  12891. NgZone.prototype._notifyOnError = function (zone, e) {
  12892. if (lang_1.isPresent(this._onErrorHandler) || async_1.ObservableWrapper.hasSubscribers(this._onErrorEvents)) {
  12893. var trace = [lang_1.normalizeBlank(e.stack)];
  12894. while (zone && zone.constructedAtException) {
  12895. trace.push(zone.constructedAtException.get());
  12896. zone = zone.parent;
  12897. }
  12898. if (async_1.ObservableWrapper.hasSubscribers(this._onErrorEvents)) {
  12899. async_1.ObservableWrapper.callEmit(this._onErrorEvents, new NgZoneError(e, trace));
  12900. }
  12901. if (lang_1.isPresent(this._onErrorHandler)) {
  12902. this._onErrorHandler(e, trace);
  12903. }
  12904. }
  12905. else {
  12906. console.log('## _notifyOnError ##');
  12907. console.log(e.stack);
  12908. throw e;
  12909. }
  12910. };
  12911. return NgZone;
  12912. })();
  12913. exports.NgZone = NgZone;
  12914. /***/ },
  12915. /* 67 */
  12916. /***/ function(module, exports, __webpack_require__) {
  12917. var di_1 = __webpack_require__(6);
  12918. var lang_1 = __webpack_require__(5);
  12919. /**
  12920. * @internal
  12921. */
  12922. exports.APP_COMPONENT_REF_PROMISE = lang_1.CONST_EXPR(new di_1.OpaqueToken('Promise<ComponentRef>'));
  12923. /**
  12924. * An {@link angular2/di/OpaqueToken} representing the application root type in the {@link
  12925. * Injector}.
  12926. *
  12927. * ```
  12928. * @Component(...)
  12929. * class MyApp {
  12930. * ...
  12931. * }
  12932. *
  12933. * bootstrap(MyApp).then((appRef:ApplicationRef) {
  12934. * expect(appRef.injector.get(appComponentTypeToken)).toEqual(MyApp);
  12935. * });
  12936. *
  12937. * ```
  12938. */
  12939. exports.APP_COMPONENT = lang_1.CONST_EXPR(new di_1.OpaqueToken('AppComponent'));
  12940. /**
  12941. * A DI Token representing a unique string id assigned to the application by Angular and used
  12942. * primarily for prefixing application attributes and CSS styles when
  12943. * {@link ViewEncapsulation#Emulated} is being used.
  12944. *
  12945. * If you need to avoid randomly generated value to be used as an application id, you can provide
  12946. * a custom value via a DI provider <!-- TODO: provider --> configuring the root {@link Injector}
  12947. * using this token.
  12948. */
  12949. exports.APP_ID = lang_1.CONST_EXPR(new di_1.OpaqueToken('AppId'));
  12950. function _appIdRandomProviderFactory() {
  12951. return "" + _randomChar() + _randomChar() + _randomChar();
  12952. }
  12953. /**
  12954. * Providers that will generate a random APP_ID_TOKEN.
  12955. */
  12956. exports.APP_ID_RANDOM_PROVIDER = lang_1.CONST_EXPR(new di_1.Provider(exports.APP_ID, { useFactory: _appIdRandomProviderFactory, deps: [] }));
  12957. function _randomChar() {
  12958. return lang_1.StringWrapper.fromCharCode(97 + lang_1.Math.floor(lang_1.Math.random() * 25));
  12959. }
  12960. /**
  12961. * A function that will be executed when a platform is initialized.
  12962. */
  12963. exports.PLATFORM_INITIALIZER = lang_1.CONST_EXPR(new di_1.OpaqueToken("Platform Initializer"));
  12964. /**
  12965. * A function that will be executed when an application is initialized.
  12966. */
  12967. exports.APP_INITIALIZER = lang_1.CONST_EXPR(new di_1.OpaqueToken("Application Initializer"));
  12968. /**
  12969. * A token which indicates the root directory of the application
  12970. */
  12971. exports.PACKAGE_ROOT_URL = lang_1.CONST_EXPR(new di_1.OpaqueToken("Application Packages Root URL"));
  12972. /***/ },
  12973. /* 68 */
  12974. /***/ function(module, exports, __webpack_require__) {
  12975. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  12976. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  12977. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  12978. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  12979. return c > 3 && r && Object.defineProperty(target, key, r), r;
  12980. };
  12981. var __metadata = (this && this.__metadata) || function (k, v) {
  12982. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  12983. };
  12984. var di_1 = __webpack_require__(6);
  12985. var collection_1 = __webpack_require__(12);
  12986. var lang_1 = __webpack_require__(5);
  12987. var exceptions_1 = __webpack_require__(14);
  12988. var ng_zone_1 = __webpack_require__(66);
  12989. var async_1 = __webpack_require__(60);
  12990. /**
  12991. * The Testability service provides testing hooks that can be accessed from
  12992. * the browser and by services such as Protractor. Each bootstrapped Angular
  12993. * application on the page will have an instance of Testability.
  12994. */
  12995. var Testability = (function () {
  12996. function Testability(_ngZone) {
  12997. /** @internal */
  12998. this._pendingCount = 0;
  12999. /** @internal */
  13000. this._callbacks = [];
  13001. /** @internal */
  13002. this._isAngularEventPending = false;
  13003. this._watchAngularEvents(_ngZone);
  13004. }
  13005. /** @internal */
  13006. Testability.prototype._watchAngularEvents = function (_ngZone) {
  13007. var _this = this;
  13008. async_1.ObservableWrapper.subscribe(_ngZone.onTurnStart, function (_) { _this._isAngularEventPending = true; });
  13009. _ngZone.runOutsideAngular(function () {
  13010. async_1.ObservableWrapper.subscribe(_ngZone.onEventDone, function (_) {
  13011. if (!_ngZone.hasPendingTimers) {
  13012. _this._isAngularEventPending = false;
  13013. _this._runCallbacksIfReady();
  13014. }
  13015. });
  13016. });
  13017. };
  13018. Testability.prototype.increasePendingRequestCount = function () {
  13019. this._pendingCount += 1;
  13020. return this._pendingCount;
  13021. };
  13022. Testability.prototype.decreasePendingRequestCount = function () {
  13023. this._pendingCount -= 1;
  13024. if (this._pendingCount < 0) {
  13025. throw new exceptions_1.BaseException('pending async requests below zero');
  13026. }
  13027. this._runCallbacksIfReady();
  13028. return this._pendingCount;
  13029. };
  13030. Testability.prototype.isStable = function () { return this._pendingCount == 0 && !this._isAngularEventPending; };
  13031. /** @internal */
  13032. Testability.prototype._runCallbacksIfReady = function () {
  13033. var _this = this;
  13034. if (!this.isStable()) {
  13035. return; // Not ready
  13036. }
  13037. // Schedules the call backs in a new frame so that it is always async.
  13038. async_1.PromiseWrapper.resolve(null).then(function (_) {
  13039. while (_this._callbacks.length !== 0) {
  13040. (_this._callbacks.pop())();
  13041. }
  13042. });
  13043. };
  13044. Testability.prototype.whenStable = function (callback) {
  13045. this._callbacks.push(callback);
  13046. this._runCallbacksIfReady();
  13047. };
  13048. Testability.prototype.getPendingRequestCount = function () { return this._pendingCount; };
  13049. // This only accounts for ngZone, and not pending counts. Use `whenStable` to
  13050. // check for stability.
  13051. Testability.prototype.isAngularEventPending = function () { return this._isAngularEventPending; };
  13052. Testability.prototype.findBindings = function (using, provider, exactMatch) {
  13053. // TODO(juliemr): implement.
  13054. return [];
  13055. };
  13056. Testability.prototype.findProviders = function (using, provider, exactMatch) {
  13057. // TODO(juliemr): implement.
  13058. return [];
  13059. };
  13060. Testability = __decorate([
  13061. di_1.Injectable(),
  13062. __metadata('design:paramtypes', [ng_zone_1.NgZone])
  13063. ], Testability);
  13064. return Testability;
  13065. })();
  13066. exports.Testability = Testability;
  13067. /**
  13068. * A global registry of {@link Testability} instances for specific elements.
  13069. */
  13070. var TestabilityRegistry = (function () {
  13071. function TestabilityRegistry() {
  13072. /** @internal */
  13073. this._applications = new collection_1.Map();
  13074. _testabilityGetter.addToWindow(this);
  13075. }
  13076. TestabilityRegistry.prototype.registerApplication = function (token, testability) {
  13077. this._applications.set(token, testability);
  13078. };
  13079. TestabilityRegistry.prototype.getTestability = function (elem) { return this._applications.get(elem); };
  13080. TestabilityRegistry.prototype.getAllTestabilities = function () { return collection_1.MapWrapper.values(this._applications); };
  13081. TestabilityRegistry.prototype.findTestabilityInTree = function (elem, findInAncestors) {
  13082. if (findInAncestors === void 0) { findInAncestors = true; }
  13083. return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
  13084. };
  13085. TestabilityRegistry = __decorate([
  13086. di_1.Injectable(),
  13087. __metadata('design:paramtypes', [])
  13088. ], TestabilityRegistry);
  13089. return TestabilityRegistry;
  13090. })();
  13091. exports.TestabilityRegistry = TestabilityRegistry;
  13092. var _NoopGetTestability = (function () {
  13093. function _NoopGetTestability() {
  13094. }
  13095. _NoopGetTestability.prototype.addToWindow = function (registry) { };
  13096. _NoopGetTestability.prototype.findTestabilityInTree = function (registry, elem, findInAncestors) {
  13097. return null;
  13098. };
  13099. _NoopGetTestability = __decorate([
  13100. lang_1.CONST(),
  13101. __metadata('design:paramtypes', [])
  13102. ], _NoopGetTestability);
  13103. return _NoopGetTestability;
  13104. })();
  13105. /**
  13106. * Set the {@link GetTestability} implementation used by the Angular testing framework.
  13107. */
  13108. function setTestabilityGetter(getter) {
  13109. _testabilityGetter = getter;
  13110. }
  13111. exports.setTestabilityGetter = setTestabilityGetter;
  13112. var _testabilityGetter = lang_1.CONST_EXPR(new _NoopGetTestability());
  13113. /***/ },
  13114. /* 69 */
  13115. /***/ function(module, exports, __webpack_require__) {
  13116. var __extends = (this && this.__extends) || function (d, b) {
  13117. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  13118. function __() { this.constructor = d; }
  13119. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13120. };
  13121. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  13122. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  13123. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  13124. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  13125. return c > 3 && r && Object.defineProperty(target, key, r), r;
  13126. };
  13127. var __metadata = (this && this.__metadata) || function (k, v) {
  13128. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  13129. };
  13130. var di_1 = __webpack_require__(6);
  13131. var compiler_1 = __webpack_require__(70);
  13132. var lang_1 = __webpack_require__(5);
  13133. var view_manager_1 = __webpack_require__(81);
  13134. /**
  13135. * Represents an instance of a Component created via {@link DynamicComponentLoader}.
  13136. *
  13137. * `ComponentRef` provides access to the Component Instance as well other objects related to this
  13138. * Component Instance and allows you to destroy the Component Instance via the {@link #dispose}
  13139. * method.
  13140. */
  13141. var ComponentRef = (function () {
  13142. function ComponentRef() {
  13143. }
  13144. Object.defineProperty(ComponentRef.prototype, "hostView", {
  13145. /**
  13146. * The {@link ViewRef} of the Host View of this Component instance.
  13147. */
  13148. get: function () { return this.location.parentView; },
  13149. enumerable: true,
  13150. configurable: true
  13151. });
  13152. Object.defineProperty(ComponentRef.prototype, "hostComponent", {
  13153. /**
  13154. * @internal
  13155. *
  13156. * The instance of the component.
  13157. *
  13158. * TODO(i): this api should be removed
  13159. */
  13160. get: function () { return this.instance; },
  13161. enumerable: true,
  13162. configurable: true
  13163. });
  13164. return ComponentRef;
  13165. })();
  13166. exports.ComponentRef = ComponentRef;
  13167. var ComponentRef_ = (function (_super) {
  13168. __extends(ComponentRef_, _super);
  13169. /**
  13170. * TODO(i): refactor into public/private fields
  13171. */
  13172. function ComponentRef_(location, instance, componentType, injector, _dispose) {
  13173. _super.call(this);
  13174. this._dispose = _dispose;
  13175. this.location = location;
  13176. this.instance = instance;
  13177. this.componentType = componentType;
  13178. this.injector = injector;
  13179. }
  13180. Object.defineProperty(ComponentRef_.prototype, "hostComponentType", {
  13181. /**
  13182. * @internal
  13183. *
  13184. * Returns the type of this Component instance.
  13185. *
  13186. * TODO(i): this api should be removed
  13187. */
  13188. get: function () { return this.componentType; },
  13189. enumerable: true,
  13190. configurable: true
  13191. });
  13192. ComponentRef_.prototype.dispose = function () { this._dispose(); };
  13193. return ComponentRef_;
  13194. })(ComponentRef);
  13195. exports.ComponentRef_ = ComponentRef_;
  13196. /**
  13197. * Service for instantiating a Component and attaching it to a View at a specified location.
  13198. */
  13199. var DynamicComponentLoader = (function () {
  13200. function DynamicComponentLoader() {
  13201. }
  13202. return DynamicComponentLoader;
  13203. })();
  13204. exports.DynamicComponentLoader = DynamicComponentLoader;
  13205. var DynamicComponentLoader_ = (function (_super) {
  13206. __extends(DynamicComponentLoader_, _super);
  13207. function DynamicComponentLoader_(_compiler, _viewManager) {
  13208. _super.call(this);
  13209. this._compiler = _compiler;
  13210. this._viewManager = _viewManager;
  13211. }
  13212. DynamicComponentLoader_.prototype.loadAsRoot = function (type, overrideSelector, injector, onDispose) {
  13213. var _this = this;
  13214. return this._compiler.compileInHost(type).then(function (hostProtoViewRef) {
  13215. var hostViewRef = _this._viewManager.createRootHostView(hostProtoViewRef, overrideSelector, injector);
  13216. var newLocation = _this._viewManager.getHostElement(hostViewRef);
  13217. var component = _this._viewManager.getComponent(newLocation);
  13218. var dispose = function () {
  13219. if (lang_1.isPresent(onDispose)) {
  13220. onDispose();
  13221. }
  13222. _this._viewManager.destroyRootHostView(hostViewRef);
  13223. };
  13224. return new ComponentRef_(newLocation, component, type, injector, dispose);
  13225. });
  13226. };
  13227. DynamicComponentLoader_.prototype.loadIntoLocation = function (type, hostLocation, anchorName, providers) {
  13228. if (providers === void 0) { providers = null; }
  13229. return this.loadNextToLocation(type, this._viewManager.getNamedElementInComponentView(hostLocation, anchorName), providers);
  13230. };
  13231. DynamicComponentLoader_.prototype.loadNextToLocation = function (type, location, providers) {
  13232. var _this = this;
  13233. if (providers === void 0) { providers = null; }
  13234. return this._compiler.compileInHost(type).then(function (hostProtoViewRef) {
  13235. var viewContainer = _this._viewManager.getViewContainer(location);
  13236. var hostViewRef = viewContainer.createHostView(hostProtoViewRef, viewContainer.length, providers);
  13237. var newLocation = _this._viewManager.getHostElement(hostViewRef);
  13238. var component = _this._viewManager.getComponent(newLocation);
  13239. var dispose = function () {
  13240. var index = viewContainer.indexOf(hostViewRef);
  13241. if (index !== -1) {
  13242. viewContainer.remove(index);
  13243. }
  13244. };
  13245. return new ComponentRef_(newLocation, component, type, null, dispose);
  13246. });
  13247. };
  13248. DynamicComponentLoader_ = __decorate([
  13249. di_1.Injectable(),
  13250. __metadata('design:paramtypes', [compiler_1.Compiler, view_manager_1.AppViewManager])
  13251. ], DynamicComponentLoader_);
  13252. return DynamicComponentLoader_;
  13253. })(DynamicComponentLoader);
  13254. exports.DynamicComponentLoader_ = DynamicComponentLoader_;
  13255. /***/ },
  13256. /* 70 */
  13257. /***/ function(module, exports, __webpack_require__) {
  13258. var __extends = (this && this.__extends) || function (d, b) {
  13259. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  13260. function __() { this.constructor = d; }
  13261. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13262. };
  13263. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  13264. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  13265. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  13266. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  13267. return c > 3 && r && Object.defineProperty(target, key, r), r;
  13268. };
  13269. var __metadata = (this && this.__metadata) || function (k, v) {
  13270. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  13271. };
  13272. var proto_view_factory_1 = __webpack_require__(71);
  13273. var di_1 = __webpack_require__(6);
  13274. var lang_1 = __webpack_require__(5);
  13275. var exceptions_1 = __webpack_require__(14);
  13276. var async_1 = __webpack_require__(60);
  13277. var reflection_1 = __webpack_require__(16);
  13278. var template_commands_1 = __webpack_require__(96);
  13279. /**
  13280. * Low-level service for compiling {@link Component}s into {@link ProtoViewRef ProtoViews}s, which
  13281. * can later be used to create and render a Component instance.
  13282. *
  13283. * Most applications should instead use higher-level {@link DynamicComponentLoader} service, which
  13284. * both compiles and instantiates a Component.
  13285. */
  13286. var Compiler = (function () {
  13287. function Compiler() {
  13288. }
  13289. return Compiler;
  13290. })();
  13291. exports.Compiler = Compiler;
  13292. function _isCompiledHostTemplate(type) {
  13293. return type instanceof template_commands_1.CompiledHostTemplate;
  13294. }
  13295. var Compiler_ = (function (_super) {
  13296. __extends(Compiler_, _super);
  13297. function Compiler_(_protoViewFactory) {
  13298. _super.call(this);
  13299. this._protoViewFactory = _protoViewFactory;
  13300. }
  13301. Compiler_.prototype.compileInHost = function (componentType) {
  13302. var metadatas = reflection_1.reflector.annotations(componentType);
  13303. var compiledHostTemplate = metadatas.find(_isCompiledHostTemplate);
  13304. if (lang_1.isBlank(compiledHostTemplate)) {
  13305. throw new exceptions_1.BaseException("No precompiled template for component " + lang_1.stringify(componentType) + " found");
  13306. }
  13307. return async_1.PromiseWrapper.resolve(this._createProtoView(compiledHostTemplate));
  13308. };
  13309. Compiler_.prototype._createProtoView = function (compiledHostTemplate) {
  13310. return this._protoViewFactory.createHost(compiledHostTemplate).ref;
  13311. };
  13312. Compiler_.prototype.clearCache = function () { this._protoViewFactory.clearCache(); };
  13313. Compiler_ = __decorate([
  13314. di_1.Injectable(),
  13315. __metadata('design:paramtypes', [proto_view_factory_1.ProtoViewFactory])
  13316. ], Compiler_);
  13317. return Compiler_;
  13318. })(Compiler);
  13319. exports.Compiler_ = Compiler_;
  13320. function internalCreateProtoView(compiler, compiledHostTemplate) {
  13321. return compiler._createProtoView(compiledHostTemplate);
  13322. }
  13323. exports.internalCreateProtoView = internalCreateProtoView;
  13324. /***/ },
  13325. /* 71 */
  13326. /***/ function(module, exports, __webpack_require__) {
  13327. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  13328. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  13329. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  13330. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  13331. return c > 3 && r && Object.defineProperty(target, key, r), r;
  13332. };
  13333. var __metadata = (this && this.__metadata) || function (k, v) {
  13334. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  13335. };
  13336. var __param = (this && this.__param) || function (paramIndex, decorator) {
  13337. return function (target, key) { decorator(target, key, paramIndex); }
  13338. };
  13339. var lang_1 = __webpack_require__(5);
  13340. var api_1 = __webpack_require__(72);
  13341. var di_1 = __webpack_require__(6);
  13342. var pipe_provider_1 = __webpack_require__(73);
  13343. var pipes_1 = __webpack_require__(74);
  13344. var view_1 = __webpack_require__(76);
  13345. var element_binder_1 = __webpack_require__(79);
  13346. var element_injector_1 = __webpack_require__(80);
  13347. var directive_resolver_1 = __webpack_require__(92);
  13348. var view_resolver_1 = __webpack_require__(93);
  13349. var pipe_resolver_1 = __webpack_require__(94);
  13350. var view_2 = __webpack_require__(56);
  13351. var platform_directives_and_pipes_1 = __webpack_require__(95);
  13352. var template_commands_1 = __webpack_require__(96);
  13353. var api_2 = __webpack_require__(72);
  13354. var application_tokens_1 = __webpack_require__(67);
  13355. var ProtoViewFactory = (function () {
  13356. function ProtoViewFactory(_renderer, _platformPipes, _directiveResolver, _viewResolver, _pipeResolver, _appId) {
  13357. this._renderer = _renderer;
  13358. this._platformPipes = _platformPipes;
  13359. this._directiveResolver = _directiveResolver;
  13360. this._viewResolver = _viewResolver;
  13361. this._pipeResolver = _pipeResolver;
  13362. this._appId = _appId;
  13363. this._cache = new Map();
  13364. this._nextTemplateId = 0;
  13365. }
  13366. ProtoViewFactory.prototype.clearCache = function () { this._cache.clear(); };
  13367. ProtoViewFactory.prototype.createHost = function (compiledHostTemplate) {
  13368. var compiledTemplate = compiledHostTemplate.template;
  13369. var result = this._cache.get(compiledTemplate.id);
  13370. if (lang_1.isBlank(result)) {
  13371. var emptyMap = {};
  13372. var shortId = this._appId + "-" + this._nextTemplateId++;
  13373. this._renderer.registerComponentTemplate(new api_1.RenderComponentTemplate(compiledTemplate.id, shortId, view_2.ViewEncapsulation.None, compiledTemplate.commands, []));
  13374. result =
  13375. new view_1.AppProtoView(compiledTemplate.id, compiledTemplate.commands, view_1.ViewType.HOST, true, compiledTemplate.changeDetectorFactory, null, new pipes_1.ProtoPipes(emptyMap));
  13376. this._cache.set(compiledTemplate.id, result);
  13377. }
  13378. return result;
  13379. };
  13380. ProtoViewFactory.prototype._createComponent = function (cmd) {
  13381. var _this = this;
  13382. var nestedProtoView = this._cache.get(cmd.templateId);
  13383. if (lang_1.isBlank(nestedProtoView)) {
  13384. var component = cmd.directives[0];
  13385. var view = this._viewResolver.resolve(component);
  13386. var compiledTemplate = cmd.templateGetter();
  13387. var styles = _flattenStyleArr(compiledTemplate.styles, []);
  13388. var shortId = this._appId + "-" + this._nextTemplateId++;
  13389. this._renderer.registerComponentTemplate(new api_1.RenderComponentTemplate(compiledTemplate.id, shortId, cmd.encapsulation, compiledTemplate.commands, styles));
  13390. var boundPipes = this._flattenPipes(view).map(function (pipe) { return _this._bindPipe(pipe); });
  13391. nestedProtoView = new view_1.AppProtoView(compiledTemplate.id, compiledTemplate.commands, view_1.ViewType.COMPONENT, true, compiledTemplate.changeDetectorFactory, null, pipes_1.ProtoPipes.fromProviders(boundPipes));
  13392. // Note: The cache is updated before recursing
  13393. // to be able to resolve cycles
  13394. this._cache.set(compiledTemplate.id, nestedProtoView);
  13395. this._initializeProtoView(nestedProtoView, null);
  13396. }
  13397. return nestedProtoView;
  13398. };
  13399. ProtoViewFactory.prototype._createEmbeddedTemplate = function (cmd, parent) {
  13400. var nestedProtoView = new view_1.AppProtoView(parent.templateId, cmd.children, view_1.ViewType.EMBEDDED, cmd.isMerged, cmd.changeDetectorFactory, arrayToMap(cmd.variableNameAndValues, true), new pipes_1.ProtoPipes(parent.pipes.config));
  13401. if (cmd.isMerged) {
  13402. this.initializeProtoViewIfNeeded(nestedProtoView);
  13403. }
  13404. return nestedProtoView;
  13405. };
  13406. ProtoViewFactory.prototype.initializeProtoViewIfNeeded = function (protoView) {
  13407. if (!protoView.isInitialized()) {
  13408. var render = this._renderer.createProtoView(protoView.templateId, protoView.templateCmds);
  13409. this._initializeProtoView(protoView, render);
  13410. }
  13411. };
  13412. ProtoViewFactory.prototype._initializeProtoView = function (protoView, render) {
  13413. var initializer = new _ProtoViewInitializer(protoView, this._directiveResolver, this);
  13414. template_commands_1.visitAllCommands(initializer, protoView.templateCmds);
  13415. var mergeInfo = new view_1.AppProtoViewMergeInfo(initializer.mergeEmbeddedViewCount, initializer.mergeElementCount, initializer.mergeViewCount);
  13416. protoView.init(render, initializer.elementBinders, initializer.boundTextCount, mergeInfo, initializer.variableLocations);
  13417. };
  13418. ProtoViewFactory.prototype._bindPipe = function (typeOrProvider) {
  13419. var meta = this._pipeResolver.resolve(typeOrProvider);
  13420. return pipe_provider_1.PipeProvider.createFromType(typeOrProvider, meta);
  13421. };
  13422. ProtoViewFactory.prototype._flattenPipes = function (view) {
  13423. var pipes = [];
  13424. if (lang_1.isPresent(this._platformPipes)) {
  13425. _flattenArray(this._platformPipes, pipes);
  13426. }
  13427. if (lang_1.isPresent(view.pipes)) {
  13428. _flattenArray(view.pipes, pipes);
  13429. }
  13430. return pipes;
  13431. };
  13432. ProtoViewFactory = __decorate([
  13433. di_1.Injectable(),
  13434. __param(1, di_1.Optional()),
  13435. __param(1, di_1.Inject(platform_directives_and_pipes_1.PLATFORM_PIPES)),
  13436. __param(5, di_1.Inject(application_tokens_1.APP_ID)),
  13437. __metadata('design:paramtypes', [api_2.Renderer, Array, directive_resolver_1.DirectiveResolver, view_resolver_1.ViewResolver, pipe_resolver_1.PipeResolver, String])
  13438. ], ProtoViewFactory);
  13439. return ProtoViewFactory;
  13440. })();
  13441. exports.ProtoViewFactory = ProtoViewFactory;
  13442. function createComponent(protoViewFactory, cmd) {
  13443. return protoViewFactory._createComponent(cmd);
  13444. }
  13445. function createEmbeddedTemplate(protoViewFactory, cmd, parent) {
  13446. return protoViewFactory._createEmbeddedTemplate(cmd, parent);
  13447. }
  13448. var _ProtoViewInitializer = (function () {
  13449. function _ProtoViewInitializer(_protoView, _directiveResolver, _protoViewFactory) {
  13450. this._protoView = _protoView;
  13451. this._directiveResolver = _directiveResolver;
  13452. this._protoViewFactory = _protoViewFactory;
  13453. this.variableLocations = new Map();
  13454. this.boundTextCount = 0;
  13455. this.boundElementIndex = 0;
  13456. this.elementBinderStack = [];
  13457. this.distanceToParentElementBinder = 0;
  13458. this.distanceToParentProtoElementInjector = 0;
  13459. this.elementBinders = [];
  13460. this.mergeEmbeddedViewCount = 0;
  13461. this.mergeElementCount = 0;
  13462. this.mergeViewCount = 1;
  13463. }
  13464. _ProtoViewInitializer.prototype.visitText = function (cmd, context) {
  13465. if (cmd.isBound) {
  13466. this.boundTextCount++;
  13467. }
  13468. return null;
  13469. };
  13470. _ProtoViewInitializer.prototype.visitNgContent = function (cmd, context) { return null; };
  13471. _ProtoViewInitializer.prototype.visitBeginElement = function (cmd, context) {
  13472. if (cmd.isBound) {
  13473. this._visitBeginBoundElement(cmd, null);
  13474. }
  13475. else {
  13476. this._visitBeginElement(cmd, null, null);
  13477. }
  13478. return null;
  13479. };
  13480. _ProtoViewInitializer.prototype.visitEndElement = function (context) { return this._visitEndElement(); };
  13481. _ProtoViewInitializer.prototype.visitBeginComponent = function (cmd, context) {
  13482. var nestedProtoView = createComponent(this._protoViewFactory, cmd);
  13483. return this._visitBeginBoundElement(cmd, nestedProtoView);
  13484. };
  13485. _ProtoViewInitializer.prototype.visitEndComponent = function (context) { return this._visitEndElement(); };
  13486. _ProtoViewInitializer.prototype.visitEmbeddedTemplate = function (cmd, context) {
  13487. var nestedProtoView = createEmbeddedTemplate(this._protoViewFactory, cmd, this._protoView);
  13488. if (cmd.isMerged) {
  13489. this.mergeEmbeddedViewCount++;
  13490. }
  13491. this._visitBeginBoundElement(cmd, nestedProtoView);
  13492. return this._visitEndElement();
  13493. };
  13494. _ProtoViewInitializer.prototype._visitBeginBoundElement = function (cmd, nestedProtoView) {
  13495. if (lang_1.isPresent(nestedProtoView) && nestedProtoView.isMergable) {
  13496. this.mergeElementCount += nestedProtoView.mergeInfo.elementCount;
  13497. this.mergeViewCount += nestedProtoView.mergeInfo.viewCount;
  13498. this.mergeEmbeddedViewCount += nestedProtoView.mergeInfo.embeddedViewCount;
  13499. }
  13500. var elementBinder = _createElementBinder(this._directiveResolver, nestedProtoView, this.elementBinderStack, this.boundElementIndex, this.distanceToParentElementBinder, this.distanceToParentProtoElementInjector, cmd);
  13501. this.elementBinders.push(elementBinder);
  13502. var protoElementInjector = elementBinder.protoElementInjector;
  13503. for (var i = 0; i < cmd.variableNameAndValues.length; i += 2) {
  13504. this.variableLocations.set(cmd.variableNameAndValues[i], this.boundElementIndex);
  13505. }
  13506. this.boundElementIndex++;
  13507. this.mergeElementCount++;
  13508. return this._visitBeginElement(cmd, elementBinder, protoElementInjector);
  13509. };
  13510. _ProtoViewInitializer.prototype._visitBeginElement = function (cmd, elementBinder, protoElementInjector) {
  13511. this.distanceToParentElementBinder =
  13512. lang_1.isPresent(elementBinder) ? 1 : this.distanceToParentElementBinder + 1;
  13513. this.distanceToParentProtoElementInjector =
  13514. lang_1.isPresent(protoElementInjector) ? 1 : this.distanceToParentProtoElementInjector + 1;
  13515. this.elementBinderStack.push(elementBinder);
  13516. return null;
  13517. };
  13518. _ProtoViewInitializer.prototype._visitEndElement = function () {
  13519. var parentElementBinder = this.elementBinderStack.pop();
  13520. var parentProtoElementInjector = lang_1.isPresent(parentElementBinder) ? parentElementBinder.protoElementInjector : null;
  13521. this.distanceToParentElementBinder = lang_1.isPresent(parentElementBinder) ?
  13522. parentElementBinder.distanceToParent :
  13523. this.distanceToParentElementBinder - 1;
  13524. this.distanceToParentProtoElementInjector = lang_1.isPresent(parentProtoElementInjector) ?
  13525. parentProtoElementInjector.distanceToParent :
  13526. this.distanceToParentProtoElementInjector - 1;
  13527. return null;
  13528. };
  13529. return _ProtoViewInitializer;
  13530. })();
  13531. function _createElementBinder(directiveResolver, nestedProtoView, elementBinderStack, boundElementIndex, distanceToParentBinder, distanceToParentPei, beginElementCmd) {
  13532. var parentElementBinder = null;
  13533. var parentProtoElementInjector = null;
  13534. if (distanceToParentBinder > 0) {
  13535. parentElementBinder = elementBinderStack[elementBinderStack.length - distanceToParentBinder];
  13536. }
  13537. if (lang_1.isBlank(parentElementBinder)) {
  13538. distanceToParentBinder = -1;
  13539. }
  13540. if (distanceToParentPei > 0) {
  13541. var peiBinder = elementBinderStack[elementBinderStack.length - distanceToParentPei];
  13542. if (lang_1.isPresent(peiBinder)) {
  13543. parentProtoElementInjector = peiBinder.protoElementInjector;
  13544. }
  13545. }
  13546. if (lang_1.isBlank(parentProtoElementInjector)) {
  13547. distanceToParentPei = -1;
  13548. }
  13549. var componentDirectiveProvider = null;
  13550. var isEmbeddedTemplate = false;
  13551. var directiveProviders = beginElementCmd.directives.map(function (type) { return provideDirective(directiveResolver, type); });
  13552. if (beginElementCmd instanceof template_commands_1.BeginComponentCmd) {
  13553. componentDirectiveProvider = directiveProviders[0];
  13554. }
  13555. else if (beginElementCmd instanceof template_commands_1.EmbeddedTemplateCmd) {
  13556. isEmbeddedTemplate = true;
  13557. }
  13558. var protoElementInjector = null;
  13559. // Create a protoElementInjector for any element that either has bindings *or* has one
  13560. // or more var- defined *or* for <template> elements:
  13561. // - Elements with a var- defined need a their own element injector
  13562. // so that, when hydrating, $implicit can be set to the element.
  13563. // - <template> elements need their own ElementInjector so that we can query their TemplateRef
  13564. var hasVariables = beginElementCmd.variableNameAndValues.length > 0;
  13565. if (directiveProviders.length > 0 || hasVariables || isEmbeddedTemplate) {
  13566. var directiveVariableBindings = new Map();
  13567. if (!isEmbeddedTemplate) {
  13568. directiveVariableBindings = createDirectiveVariableBindings(beginElementCmd.variableNameAndValues, directiveProviders);
  13569. }
  13570. protoElementInjector = element_injector_1.ProtoElementInjector.create(parentProtoElementInjector, boundElementIndex, directiveProviders, lang_1.isPresent(componentDirectiveProvider), distanceToParentPei, directiveVariableBindings);
  13571. protoElementInjector.attributes = arrayToMap(beginElementCmd.attrNameAndValues, false);
  13572. }
  13573. return new element_binder_1.ElementBinder(boundElementIndex, parentElementBinder, distanceToParentBinder, protoElementInjector, componentDirectiveProvider, nestedProtoView);
  13574. }
  13575. function provideDirective(directiveResolver, type) {
  13576. var annotation = directiveResolver.resolve(type);
  13577. return element_injector_1.DirectiveProvider.createFromType(type, annotation);
  13578. }
  13579. function createDirectiveVariableBindings(variableNameAndValues, directiveProviders) {
  13580. var directiveVariableBindings = new Map();
  13581. for (var i = 0; i < variableNameAndValues.length; i += 2) {
  13582. var templateName = variableNameAndValues[i];
  13583. var dirIndex = variableNameAndValues[i + 1];
  13584. if (lang_1.isNumber(dirIndex)) {
  13585. directiveVariableBindings.set(templateName, dirIndex);
  13586. }
  13587. else {
  13588. // a variable without a directive index -> reference the element
  13589. directiveVariableBindings.set(templateName, null);
  13590. }
  13591. }
  13592. return directiveVariableBindings;
  13593. }
  13594. exports.createDirectiveVariableBindings = createDirectiveVariableBindings;
  13595. function arrayToMap(arr, inverse) {
  13596. var result = new Map();
  13597. for (var i = 0; i < arr.length; i += 2) {
  13598. if (inverse) {
  13599. result.set(arr[i + 1], arr[i]);
  13600. }
  13601. else {
  13602. result.set(arr[i], arr[i + 1]);
  13603. }
  13604. }
  13605. return result;
  13606. }
  13607. function _flattenArray(tree, out) {
  13608. for (var i = 0; i < tree.length; i++) {
  13609. var item = di_1.resolveForwardRef(tree[i]);
  13610. if (lang_1.isArray(item)) {
  13611. _flattenArray(item, out);
  13612. }
  13613. else {
  13614. out.push(item);
  13615. }
  13616. }
  13617. }
  13618. function _flattenStyleArr(arr, out) {
  13619. for (var i = 0; i < arr.length; i++) {
  13620. var entry = arr[i];
  13621. if (lang_1.isArray(entry)) {
  13622. _flattenStyleArr(entry, out);
  13623. }
  13624. else {
  13625. out.push(entry);
  13626. }
  13627. }
  13628. return out;
  13629. }
  13630. /***/ },
  13631. /* 72 */
  13632. /***/ function(module, exports, __webpack_require__) {
  13633. var __extends = (this && this.__extends) || function (d, b) {
  13634. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  13635. function __() { this.constructor = d; }
  13636. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13637. };
  13638. var exceptions_1 = __webpack_require__(14);
  13639. /**
  13640. * Represents an Angular ProtoView in the Rendering Context.
  13641. *
  13642. * When you implement a custom {@link Renderer}, `RenderProtoViewRef` specifies what Render View
  13643. * your renderer should create.
  13644. *
  13645. * `RenderProtoViewRef` is a counterpart to {@link ProtoViewRef} available in the Application
  13646. * Context. But unlike `ProtoViewRef`, `RenderProtoViewRef` contains all static nested Proto Views
  13647. * that are recursively merged into a single Render Proto View.
  13648. *
  13649. * <!-- TODO: this is created by Renderer#createProtoView in the new compiler -->
  13650. */
  13651. var RenderProtoViewRef = (function () {
  13652. function RenderProtoViewRef() {
  13653. }
  13654. return RenderProtoViewRef;
  13655. })();
  13656. exports.RenderProtoViewRef = RenderProtoViewRef;
  13657. /**
  13658. * Represents a list of sibling Nodes that can be moved by the {@link Renderer} independently of
  13659. * other Render Fragments.
  13660. *
  13661. * Any {@link RenderViewRef} has one Render Fragment.
  13662. *
  13663. * Additionally any View with an Embedded View that contains a {@link NgContentAst View Projection}
  13664. * results in additional Render Fragment.
  13665. */
  13666. /*
  13667. <div>foo</div>
  13668. {{bar}}
  13669. <div>foo</div> -> view 1 / fragment 1
  13670. <ul>
  13671. <template ngFor>
  13672. <li>{{fg}}</li> -> view 2 / fragment 1
  13673. </template>
  13674. </ul>
  13675. {{bar}}
  13676. <div>foo</div> -> view 1 / fragment 1
  13677. <ul>
  13678. <template ngIf>
  13679. <li><ng-content></></li> -> view 1 / fragment 2
  13680. </template>
  13681. <template ngFor>
  13682. <li><ng-content></></li> ->
  13683. <li></li> -> view 1 / fragment 2 + view 2 / fragment 1..n-1
  13684. </template>
  13685. </ul>
  13686. {{bar}}
  13687. */
  13688. // TODO(i): refactor into an interface
  13689. var RenderFragmentRef = (function () {
  13690. function RenderFragmentRef() {
  13691. }
  13692. return RenderFragmentRef;
  13693. })();
  13694. exports.RenderFragmentRef = RenderFragmentRef;
  13695. /**
  13696. * Represents an Angular View in the Rendering Context.
  13697. *
  13698. * `RenderViewRef` specifies to the {@link Renderer} what View to update or destroy.
  13699. *
  13700. * Unlike a {@link ViewRef} available in the Application Context, Render View contains all the
  13701. * static Component Views that have been recursively merged into a single Render View.
  13702. *
  13703. * Each `RenderViewRef` contains one or more {@link RenderFragmentRef Render Fragments}, these
  13704. * Fragments are created, hydrated, dehydrated and destroyed as a single unit together with the
  13705. * View.
  13706. */
  13707. // TODO(i): refactor into an interface
  13708. var RenderViewRef = (function () {
  13709. function RenderViewRef() {
  13710. }
  13711. return RenderViewRef;
  13712. })();
  13713. exports.RenderViewRef = RenderViewRef;
  13714. /**
  13715. * Abstract base class for commands to the Angular renderer, using the visitor pattern.
  13716. */
  13717. var RenderTemplateCmd = (function () {
  13718. function RenderTemplateCmd() {
  13719. }
  13720. return RenderTemplateCmd;
  13721. })();
  13722. exports.RenderTemplateCmd = RenderTemplateCmd;
  13723. /**
  13724. * Command to begin rendering.
  13725. */
  13726. var RenderBeginCmd = (function (_super) {
  13727. __extends(RenderBeginCmd, _super);
  13728. function RenderBeginCmd() {
  13729. _super.apply(this, arguments);
  13730. }
  13731. Object.defineProperty(RenderBeginCmd.prototype, "ngContentIndex", {
  13732. get: function () { return exceptions_1.unimplemented(); },
  13733. enumerable: true,
  13734. configurable: true
  13735. });
  13736. ;
  13737. Object.defineProperty(RenderBeginCmd.prototype, "isBound", {
  13738. get: function () { return exceptions_1.unimplemented(); },
  13739. enumerable: true,
  13740. configurable: true
  13741. });
  13742. ;
  13743. return RenderBeginCmd;
  13744. })(RenderTemplateCmd);
  13745. exports.RenderBeginCmd = RenderBeginCmd;
  13746. /**
  13747. * Command to render text.
  13748. */
  13749. var RenderTextCmd = (function (_super) {
  13750. __extends(RenderTextCmd, _super);
  13751. function RenderTextCmd() {
  13752. _super.apply(this, arguments);
  13753. }
  13754. Object.defineProperty(RenderTextCmd.prototype, "value", {
  13755. get: function () { return exceptions_1.unimplemented(); },
  13756. enumerable: true,
  13757. configurable: true
  13758. });
  13759. ;
  13760. return RenderTextCmd;
  13761. })(RenderBeginCmd);
  13762. exports.RenderTextCmd = RenderTextCmd;
  13763. /**
  13764. * Command to render projected content.
  13765. */
  13766. var RenderNgContentCmd = (function (_super) {
  13767. __extends(RenderNgContentCmd, _super);
  13768. function RenderNgContentCmd() {
  13769. _super.apply(this, arguments);
  13770. }
  13771. Object.defineProperty(RenderNgContentCmd.prototype, "index", {
  13772. // The index of this NgContent element
  13773. get: function () { return exceptions_1.unimplemented(); },
  13774. enumerable: true,
  13775. configurable: true
  13776. });
  13777. ;
  13778. Object.defineProperty(RenderNgContentCmd.prototype, "ngContentIndex", {
  13779. // The index of the NgContent element into which this
  13780. // NgContent element should be projected (if any)
  13781. get: function () { return exceptions_1.unimplemented(); },
  13782. enumerable: true,
  13783. configurable: true
  13784. });
  13785. ;
  13786. return RenderNgContentCmd;
  13787. })(RenderTemplateCmd);
  13788. exports.RenderNgContentCmd = RenderNgContentCmd;
  13789. /**
  13790. * Command to begin rendering an element.
  13791. */
  13792. var RenderBeginElementCmd = (function (_super) {
  13793. __extends(RenderBeginElementCmd, _super);
  13794. function RenderBeginElementCmd() {
  13795. _super.apply(this, arguments);
  13796. }
  13797. Object.defineProperty(RenderBeginElementCmd.prototype, "name", {
  13798. get: function () { return exceptions_1.unimplemented(); },
  13799. enumerable: true,
  13800. configurable: true
  13801. });
  13802. ;
  13803. Object.defineProperty(RenderBeginElementCmd.prototype, "attrNameAndValues", {
  13804. get: function () { return exceptions_1.unimplemented(); },
  13805. enumerable: true,
  13806. configurable: true
  13807. });
  13808. ;
  13809. Object.defineProperty(RenderBeginElementCmd.prototype, "eventTargetAndNames", {
  13810. get: function () { return exceptions_1.unimplemented(); },
  13811. enumerable: true,
  13812. configurable: true
  13813. });
  13814. ;
  13815. return RenderBeginElementCmd;
  13816. })(RenderBeginCmd);
  13817. exports.RenderBeginElementCmd = RenderBeginElementCmd;
  13818. /**
  13819. * Command to begin rendering a component.
  13820. */
  13821. var RenderBeginComponentCmd = (function (_super) {
  13822. __extends(RenderBeginComponentCmd, _super);
  13823. function RenderBeginComponentCmd() {
  13824. _super.apply(this, arguments);
  13825. }
  13826. Object.defineProperty(RenderBeginComponentCmd.prototype, "templateId", {
  13827. get: function () { return exceptions_1.unimplemented(); },
  13828. enumerable: true,
  13829. configurable: true
  13830. });
  13831. ;
  13832. return RenderBeginComponentCmd;
  13833. })(RenderBeginElementCmd);
  13834. exports.RenderBeginComponentCmd = RenderBeginComponentCmd;
  13835. /**
  13836. * Command to render a component's template.
  13837. */
  13838. var RenderEmbeddedTemplateCmd = (function (_super) {
  13839. __extends(RenderEmbeddedTemplateCmd, _super);
  13840. function RenderEmbeddedTemplateCmd() {
  13841. _super.apply(this, arguments);
  13842. }
  13843. Object.defineProperty(RenderEmbeddedTemplateCmd.prototype, "isMerged", {
  13844. get: function () { return exceptions_1.unimplemented(); },
  13845. enumerable: true,
  13846. configurable: true
  13847. });
  13848. ;
  13849. Object.defineProperty(RenderEmbeddedTemplateCmd.prototype, "children", {
  13850. get: function () { return exceptions_1.unimplemented(); },
  13851. enumerable: true,
  13852. configurable: true
  13853. });
  13854. ;
  13855. return RenderEmbeddedTemplateCmd;
  13856. })(RenderBeginElementCmd);
  13857. exports.RenderEmbeddedTemplateCmd = RenderEmbeddedTemplateCmd;
  13858. /**
  13859. * Container class produced by a {@link Renderer} when creating a Render View.
  13860. *
  13861. * An instance of `RenderViewWithFragments` contains a {@link RenderViewRef} and an array of
  13862. * {@link RenderFragmentRef}s belonging to this Render View.
  13863. */
  13864. // TODO(i): refactor this by RenderViewWithFragments and adding fragments directly to RenderViewRef
  13865. var RenderViewWithFragments = (function () {
  13866. function RenderViewWithFragments(
  13867. /**
  13868. * Reference to the {@link RenderViewRef}.
  13869. */
  13870. viewRef,
  13871. /**
  13872. * Array of {@link RenderFragmentRef}s ordered in the depth-first order.
  13873. */
  13874. fragmentRefs) {
  13875. this.viewRef = viewRef;
  13876. this.fragmentRefs = fragmentRefs;
  13877. }
  13878. return RenderViewWithFragments;
  13879. })();
  13880. exports.RenderViewWithFragments = RenderViewWithFragments;
  13881. /**
  13882. * Template for rendering a component, including commands and styles.
  13883. */
  13884. var RenderComponentTemplate = (function () {
  13885. function RenderComponentTemplate(id, shortId, encapsulation, commands, styles) {
  13886. this.id = id;
  13887. this.shortId = shortId;
  13888. this.encapsulation = encapsulation;
  13889. this.commands = commands;
  13890. this.styles = styles;
  13891. }
  13892. return RenderComponentTemplate;
  13893. })();
  13894. exports.RenderComponentTemplate = RenderComponentTemplate;
  13895. /**
  13896. * Injectable service that provides a low-level interface for modifying the UI.
  13897. *
  13898. * Use this service to bypass Angular's templating and make custom UI changes that can't be
  13899. * expressed declaratively. For example if you need to set a property or an attribute whose name is
  13900. * not statically known, use {@link #setElementProperty} or {@link #setElementAttribute}
  13901. * respectively.
  13902. *
  13903. * If you are implementing a custom renderer, you must implement this interface.
  13904. *
  13905. * The default Renderer implementation is `DomRenderer`. Also available is `WebWorkerRenderer`.
  13906. */
  13907. var Renderer = (function () {
  13908. function Renderer() {
  13909. }
  13910. return Renderer;
  13911. })();
  13912. exports.Renderer = Renderer;
  13913. /***/ },
  13914. /* 73 */
  13915. /***/ function(module, exports, __webpack_require__) {
  13916. var __extends = (this && this.__extends) || function (d, b) {
  13917. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  13918. function __() { this.constructor = d; }
  13919. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13920. };
  13921. var provider_1 = __webpack_require__(13);
  13922. var di_1 = __webpack_require__(6);
  13923. var PipeProvider = (function (_super) {
  13924. __extends(PipeProvider, _super);
  13925. function PipeProvider(name, pure, key, resolvedFactories, multiBinding) {
  13926. _super.call(this, key, resolvedFactories, multiBinding);
  13927. this.name = name;
  13928. this.pure = pure;
  13929. }
  13930. PipeProvider.createFromType = function (type, metadata) {
  13931. var provider = new di_1.Provider(type, { useClass: type });
  13932. var rb = provider_1.resolveProvider(provider);
  13933. return new PipeProvider(metadata.name, metadata.pure, rb.key, rb.resolvedFactories, rb.multiProvider);
  13934. };
  13935. return PipeProvider;
  13936. })(provider_1.ResolvedProvider_);
  13937. exports.PipeProvider = PipeProvider;
  13938. /***/ },
  13939. /* 74 */
  13940. /***/ function(module, exports, __webpack_require__) {
  13941. var lang_1 = __webpack_require__(5);
  13942. var exceptions_1 = __webpack_require__(14);
  13943. var collection_1 = __webpack_require__(12);
  13944. var cd = __webpack_require__(75);
  13945. var ProtoPipes = (function () {
  13946. function ProtoPipes(
  13947. /**
  13948. * Map of {@link PipeMetadata} names to {@link PipeMetadata} implementations.
  13949. */
  13950. config) {
  13951. this.config = config;
  13952. this.config = config;
  13953. }
  13954. ProtoPipes.fromProviders = function (providers) {
  13955. var config = {};
  13956. providers.forEach(function (b) { return config[b.name] = b; });
  13957. return new ProtoPipes(config);
  13958. };
  13959. ProtoPipes.prototype.get = function (name) {
  13960. var provider = this.config[name];
  13961. if (lang_1.isBlank(provider))
  13962. throw new exceptions_1.BaseException("Cannot find pipe '" + name + "'.");
  13963. return provider;
  13964. };
  13965. return ProtoPipes;
  13966. })();
  13967. exports.ProtoPipes = ProtoPipes;
  13968. var Pipes = (function () {
  13969. function Pipes(proto, injector) {
  13970. this.proto = proto;
  13971. this.injector = injector;
  13972. /** @internal */
  13973. this._config = {};
  13974. }
  13975. Pipes.prototype.get = function (name) {
  13976. var cached = collection_1.StringMapWrapper.get(this._config, name);
  13977. if (lang_1.isPresent(cached))
  13978. return cached;
  13979. var p = this.proto.get(name);
  13980. var transform = this.injector.instantiateResolved(p);
  13981. var res = new cd.SelectedPipe(transform, p.pure);
  13982. if (p.pure) {
  13983. collection_1.StringMapWrapper.set(this._config, name, res);
  13984. }
  13985. return res;
  13986. };
  13987. return Pipes;
  13988. })();
  13989. exports.Pipes = Pipes;
  13990. /***/ },
  13991. /* 75 */
  13992. /***/ function(module, exports) {
  13993. var SelectedPipe = (function () {
  13994. function SelectedPipe(pipe, pure) {
  13995. this.pipe = pipe;
  13996. this.pure = pure;
  13997. }
  13998. return SelectedPipe;
  13999. })();
  14000. exports.SelectedPipe = SelectedPipe;
  14001. /***/ },
  14002. /* 76 */
  14003. /***/ function(module, exports, __webpack_require__) {
  14004. var __extends = (this && this.__extends) || function (d, b) {
  14005. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  14006. function __() { this.constructor = d; }
  14007. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14008. };
  14009. var collection_1 = __webpack_require__(12);
  14010. var change_detection_1 = __webpack_require__(25);
  14011. var interfaces_1 = __webpack_require__(35);
  14012. var lang_1 = __webpack_require__(5);
  14013. var exceptions_1 = __webpack_require__(14);
  14014. var view_ref_1 = __webpack_require__(77);
  14015. var util_1 = __webpack_require__(78);
  14016. var view_ref_2 = __webpack_require__(77);
  14017. var interfaces_2 = __webpack_require__(35);
  14018. exports.DebugContext = interfaces_2.DebugContext;
  14019. var REFLECT_PREFIX = 'ng-reflect-';
  14020. (function (ViewType) {
  14021. // A view that contains the host element with bound component directive.
  14022. // Contains a COMPONENT view
  14023. ViewType[ViewType["HOST"] = 0] = "HOST";
  14024. // The view of the component
  14025. // Can contain 0 to n EMBEDDED views
  14026. ViewType[ViewType["COMPONENT"] = 1] = "COMPONENT";
  14027. // A view that is embedded into another View via a <template> element
  14028. // inside of a COMPONENT view
  14029. ViewType[ViewType["EMBEDDED"] = 2] = "EMBEDDED";
  14030. })(exports.ViewType || (exports.ViewType = {}));
  14031. var ViewType = exports.ViewType;
  14032. var AppViewContainer = (function () {
  14033. function AppViewContainer() {
  14034. // The order in this list matches the DOM order.
  14035. this.views = [];
  14036. }
  14037. return AppViewContainer;
  14038. })();
  14039. exports.AppViewContainer = AppViewContainer;
  14040. /**
  14041. * Cost of making objects: http://jsperf.com/instantiate-size-of-object
  14042. *
  14043. */
  14044. var AppView = (function () {
  14045. function AppView(renderer, proto, viewOffset, elementOffset, textOffset, protoLocals, render, renderFragment, containerElementInjector) {
  14046. this.renderer = renderer;
  14047. this.proto = proto;
  14048. this.viewOffset = viewOffset;
  14049. this.elementOffset = elementOffset;
  14050. this.textOffset = textOffset;
  14051. this.render = render;
  14052. this.renderFragment = renderFragment;
  14053. this.containerElementInjector = containerElementInjector;
  14054. // AppViews that have been merged in depth first order.
  14055. // This list is shared between all merged views. Use this.elementOffset to get the local
  14056. // entries.
  14057. this.views = null;
  14058. // ElementInjectors of all AppViews in views grouped by view.
  14059. // This list is shared between all merged views. Use this.elementOffset to get the local
  14060. // entries.
  14061. this.elementInjectors = null;
  14062. // ViewContainers of all AppViews in views grouped by view.
  14063. // This list is shared between all merged views. Use this.elementOffset to get the local
  14064. // entries.
  14065. this.viewContainers = null;
  14066. // PreBuiltObjects of all AppViews in views grouped by view.
  14067. // This list is shared between all merged views. Use this.elementOffset to get the local
  14068. // entries.
  14069. this.preBuiltObjects = null;
  14070. this.changeDetector = null;
  14071. /**
  14072. * The context against which data-binding expressions in this view are evaluated against.
  14073. * This is always a component instance.
  14074. */
  14075. this.context = null;
  14076. this.ref = new view_ref_2.ViewRef_(this);
  14077. this.locals = new change_detection_1.Locals(null, collection_1.MapWrapper.clone(protoLocals)); // TODO optimize this
  14078. }
  14079. AppView.prototype.init = function (changeDetector, elementInjectors, rootElementInjectors, preBuiltObjects, views, elementRefs, viewContainers) {
  14080. this.changeDetector = changeDetector;
  14081. this.elementInjectors = elementInjectors;
  14082. this.rootElementInjectors = rootElementInjectors;
  14083. this.preBuiltObjects = preBuiltObjects;
  14084. this.views = views;
  14085. this.elementRefs = elementRefs;
  14086. this.viewContainers = viewContainers;
  14087. };
  14088. AppView.prototype.setLocal = function (contextName, value) {
  14089. if (!this.hydrated())
  14090. throw new exceptions_1.BaseException('Cannot set locals on dehydrated view.');
  14091. if (!this.proto.templateVariableBindings.has(contextName)) {
  14092. return;
  14093. }
  14094. var templateName = this.proto.templateVariableBindings.get(contextName);
  14095. this.locals.set(templateName, value);
  14096. };
  14097. AppView.prototype.hydrated = function () { return lang_1.isPresent(this.context); };
  14098. /**
  14099. * Triggers the event handlers for the element and the directives.
  14100. *
  14101. * This method is intended to be called from directive EventEmitters.
  14102. *
  14103. * @param {string} eventName
  14104. * @param {*} eventObj
  14105. * @param {number} boundElementIndex
  14106. */
  14107. AppView.prototype.triggerEventHandlers = function (eventName, eventObj, boundElementIndex) {
  14108. var locals = new collection_1.Map();
  14109. locals.set('$event', eventObj);
  14110. this.dispatchEvent(boundElementIndex, eventName, locals);
  14111. };
  14112. // dispatch to element injector or text nodes based on context
  14113. AppView.prototype.notifyOnBinding = function (b, currentValue) {
  14114. if (b.isTextNode()) {
  14115. this.renderer.setText(this.render, b.elementIndex + this.textOffset, currentValue);
  14116. }
  14117. else {
  14118. var elementRef = this.elementRefs[this.elementOffset + b.elementIndex];
  14119. if (b.isElementProperty()) {
  14120. this.renderer.setElementProperty(elementRef, b.name, currentValue);
  14121. }
  14122. else if (b.isElementAttribute()) {
  14123. this.renderer.setElementAttribute(elementRef, b.name, lang_1.isPresent(currentValue) ? "" + currentValue : null);
  14124. }
  14125. else if (b.isElementClass()) {
  14126. this.renderer.setElementClass(elementRef, b.name, currentValue);
  14127. }
  14128. else if (b.isElementStyle()) {
  14129. var unit = lang_1.isPresent(b.unit) ? b.unit : '';
  14130. this.renderer.setElementStyle(elementRef, b.name, lang_1.isPresent(currentValue) ? "" + currentValue + unit : null);
  14131. }
  14132. else {
  14133. throw new exceptions_1.BaseException('Unsupported directive record');
  14134. }
  14135. }
  14136. };
  14137. AppView.prototype.logBindingUpdate = function (b, value) {
  14138. if (b.isDirective() || b.isElementProperty()) {
  14139. var elementRef = this.elementRefs[this.elementOffset + b.elementIndex];
  14140. this.renderer.setBindingDebugInfo(elementRef, "" + REFLECT_PREFIX + util_1.camelCaseToDashCase(b.name), "" + value);
  14141. }
  14142. };
  14143. AppView.prototype.notifyAfterContentChecked = function () {
  14144. var eiCount = this.proto.elementBinders.length;
  14145. var ei = this.elementInjectors;
  14146. for (var i = eiCount - 1; i >= 0; i--) {
  14147. if (lang_1.isPresent(ei[i + this.elementOffset]))
  14148. ei[i + this.elementOffset].ngAfterContentChecked();
  14149. }
  14150. };
  14151. AppView.prototype.notifyAfterViewChecked = function () {
  14152. var eiCount = this.proto.elementBinders.length;
  14153. var ei = this.elementInjectors;
  14154. for (var i = eiCount - 1; i >= 0; i--) {
  14155. if (lang_1.isPresent(ei[i + this.elementOffset]))
  14156. ei[i + this.elementOffset].ngAfterViewChecked();
  14157. }
  14158. };
  14159. AppView.prototype.getDirectiveFor = function (directive) {
  14160. var elementInjector = this.elementInjectors[this.elementOffset + directive.elementIndex];
  14161. return elementInjector.getDirectiveAtIndex(directive.directiveIndex);
  14162. };
  14163. AppView.prototype.getNestedView = function (boundElementIndex) {
  14164. var eli = this.elementInjectors[boundElementIndex];
  14165. return lang_1.isPresent(eli) ? eli.getNestedView() : null;
  14166. };
  14167. AppView.prototype.getContainerElement = function () {
  14168. return lang_1.isPresent(this.containerElementInjector) ?
  14169. this.containerElementInjector.getElementRef() :
  14170. null;
  14171. };
  14172. AppView.prototype.getDebugContext = function (elementIndex, directiveIndex) {
  14173. try {
  14174. var offsettedIndex = this.elementOffset + elementIndex;
  14175. var hasRefForIndex = offsettedIndex < this.elementRefs.length;
  14176. var elementRef = hasRefForIndex ? this.elementRefs[this.elementOffset + elementIndex] : null;
  14177. var container = this.getContainerElement();
  14178. var ei = hasRefForIndex ? this.elementInjectors[this.elementOffset + elementIndex] : null;
  14179. var element = lang_1.isPresent(elementRef) ? elementRef.nativeElement : null;
  14180. var componentElement = lang_1.isPresent(container) ? container.nativeElement : null;
  14181. var directive = lang_1.isPresent(directiveIndex) ? this.getDirectiveFor(directiveIndex) : null;
  14182. var injector = lang_1.isPresent(ei) ? ei.getInjector() : null;
  14183. return new interfaces_1.DebugContext(element, componentElement, directive, this.context, _localsToStringMap(this.locals), injector);
  14184. }
  14185. catch (e) {
  14186. // TODO: vsavkin log the exception once we have a good way to log errors and warnings
  14187. // if an error happens during getting the debug context, we return null.
  14188. return null;
  14189. }
  14190. };
  14191. AppView.prototype.getDetectorFor = function (directive) {
  14192. var childView = this.getNestedView(this.elementOffset + directive.elementIndex);
  14193. return lang_1.isPresent(childView) ? childView.changeDetector : null;
  14194. };
  14195. AppView.prototype.invokeElementMethod = function (elementIndex, methodName, args) {
  14196. this.renderer.invokeElementMethod(this.elementRefs[elementIndex], methodName, args);
  14197. };
  14198. // implementation of RenderEventDispatcher#dispatchRenderEvent
  14199. AppView.prototype.dispatchRenderEvent = function (boundElementIndex, eventName, locals) {
  14200. var elementRef = this.elementRefs[boundElementIndex];
  14201. var view = view_ref_1.internalView(elementRef.parentView);
  14202. return view.dispatchEvent(elementRef.boundElementIndex, eventName, locals);
  14203. };
  14204. // returns false if preventDefault must be applied to the DOM event
  14205. AppView.prototype.dispatchEvent = function (boundElementIndex, eventName, locals) {
  14206. try {
  14207. if (this.hydrated()) {
  14208. return !this.changeDetector.handleEvent(eventName, boundElementIndex - this.elementOffset, new change_detection_1.Locals(this.locals, locals));
  14209. }
  14210. else {
  14211. return true;
  14212. }
  14213. }
  14214. catch (e) {
  14215. var c = this.getDebugContext(boundElementIndex - this.elementOffset, null);
  14216. var context = lang_1.isPresent(c) ? new _Context(c.element, c.componentElement, c.context, c.locals, c.injector) :
  14217. null;
  14218. throw new EventEvaluationError(eventName, e, e.stack, context);
  14219. }
  14220. };
  14221. Object.defineProperty(AppView.prototype, "ownBindersCount", {
  14222. get: function () { return this.proto.elementBinders.length; },
  14223. enumerable: true,
  14224. configurable: true
  14225. });
  14226. return AppView;
  14227. })();
  14228. exports.AppView = AppView;
  14229. function _localsToStringMap(locals) {
  14230. var res = {};
  14231. var c = locals;
  14232. while (lang_1.isPresent(c)) {
  14233. res = collection_1.StringMapWrapper.merge(res, collection_1.MapWrapper.toStringMap(c.current));
  14234. c = c.parent;
  14235. }
  14236. return res;
  14237. }
  14238. /**
  14239. * Error context included when an event handler throws an exception.
  14240. */
  14241. var _Context = (function () {
  14242. function _Context(element, componentElement, context, locals, injector) {
  14243. this.element = element;
  14244. this.componentElement = componentElement;
  14245. this.context = context;
  14246. this.locals = locals;
  14247. this.injector = injector;
  14248. }
  14249. return _Context;
  14250. })();
  14251. /**
  14252. * Wraps an exception thrown by an event handler.
  14253. */
  14254. var EventEvaluationError = (function (_super) {
  14255. __extends(EventEvaluationError, _super);
  14256. function EventEvaluationError(eventName, originalException, originalStack, context) {
  14257. _super.call(this, "Error during evaluation of \"" + eventName + "\"", originalException, originalStack, context);
  14258. }
  14259. return EventEvaluationError;
  14260. })(exceptions_1.WrappedException);
  14261. var AppProtoViewMergeInfo = (function () {
  14262. function AppProtoViewMergeInfo(embeddedViewCount, elementCount, viewCount) {
  14263. this.embeddedViewCount = embeddedViewCount;
  14264. this.elementCount = elementCount;
  14265. this.viewCount = viewCount;
  14266. }
  14267. return AppProtoViewMergeInfo;
  14268. })();
  14269. exports.AppProtoViewMergeInfo = AppProtoViewMergeInfo;
  14270. /**
  14271. *
  14272. */
  14273. var AppProtoView = (function () {
  14274. function AppProtoView(templateId, templateCmds, type, isMergable, changeDetectorFactory, templateVariableBindings, pipes) {
  14275. this.templateId = templateId;
  14276. this.templateCmds = templateCmds;
  14277. this.type = type;
  14278. this.isMergable = isMergable;
  14279. this.changeDetectorFactory = changeDetectorFactory;
  14280. this.templateVariableBindings = templateVariableBindings;
  14281. this.pipes = pipes;
  14282. this.elementBinders = null;
  14283. this.mergeInfo = null;
  14284. this.variableLocations = null;
  14285. this.textBindingCount = null;
  14286. this.render = null;
  14287. this.ref = new view_ref_2.ProtoViewRef_(this);
  14288. }
  14289. AppProtoView.prototype.init = function (render, elementBinders, textBindingCount, mergeInfo, variableLocations) {
  14290. var _this = this;
  14291. this.render = render;
  14292. this.elementBinders = elementBinders;
  14293. this.textBindingCount = textBindingCount;
  14294. this.mergeInfo = mergeInfo;
  14295. this.variableLocations = variableLocations;
  14296. this.protoLocals = new collection_1.Map();
  14297. if (lang_1.isPresent(this.templateVariableBindings)) {
  14298. this.templateVariableBindings.forEach(function (templateName, _) { _this.protoLocals.set(templateName, null); });
  14299. }
  14300. if (lang_1.isPresent(variableLocations)) {
  14301. // The view's locals needs to have a full set of variable names at construction time
  14302. // in order to prevent new variables from being set later in the lifecycle. Since we don't
  14303. // want
  14304. // to actually create variable bindings for the $implicit bindings, add to the
  14305. // protoLocals manually.
  14306. variableLocations.forEach(function (_, templateName) { _this.protoLocals.set(templateName, null); });
  14307. }
  14308. };
  14309. AppProtoView.prototype.isInitialized = function () { return lang_1.isPresent(this.elementBinders); };
  14310. return AppProtoView;
  14311. })();
  14312. exports.AppProtoView = AppProtoView;
  14313. /***/ },
  14314. /* 77 */
  14315. /***/ function(module, exports, __webpack_require__) {
  14316. var __extends = (this && this.__extends) || function (d, b) {
  14317. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  14318. function __() { this.constructor = d; }
  14319. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14320. };
  14321. var lang_1 = __webpack_require__(5);
  14322. var exceptions_1 = __webpack_require__(14);
  14323. // This is a workaround for privacy in Dart as we don't have library parts
  14324. function internalView(viewRef) {
  14325. return viewRef._view;
  14326. }
  14327. exports.internalView = internalView;
  14328. // This is a workaround for privacy in Dart as we don't have library parts
  14329. function internalProtoView(protoViewRef) {
  14330. return lang_1.isPresent(protoViewRef) ? protoViewRef._protoView : null;
  14331. }
  14332. exports.internalProtoView = internalProtoView;
  14333. /**
  14334. * Represents an Angular View.
  14335. *
  14336. * <!-- TODO: move the next two paragraphs to the dev guide -->
  14337. * A View is a fundamental building block of the application UI. It is the smallest grouping of
  14338. * Elements which are created and destroyed together.
  14339. *
  14340. * Properties of elements in a View can change, but the structure (number and order) of elements in
  14341. * a View cannot. Changing the structure of Elements can only be done by inserting, moving or
  14342. * removing nested Views via a {@link ViewContainerRef}. Each View can contain many View Containers.
  14343. * <!-- /TODO -->
  14344. *
  14345. * ### Example
  14346. *
  14347. * Given this template...
  14348. *
  14349. * ```
  14350. * Count: {{items.length}}
  14351. * <ul>
  14352. * <li *ngFor="var item of items">{{item}}</li>
  14353. * </ul>
  14354. * ```
  14355. *
  14356. * ... we have two {@link ProtoViewRef}s:
  14357. *
  14358. * Outer {@link ProtoViewRef}:
  14359. * ```
  14360. * Count: {{items.length}}
  14361. * <ul>
  14362. * <template ngFor var-item [ngForOf]="items"></template>
  14363. * </ul>
  14364. * ```
  14365. *
  14366. * Inner {@link ProtoViewRef}:
  14367. * ```
  14368. * <li>{{item}}</li>
  14369. * ```
  14370. *
  14371. * Notice that the original template is broken down into two separate {@link ProtoViewRef}s.
  14372. *
  14373. * The outer/inner {@link ProtoViewRef}s are then assembled into views like so:
  14374. *
  14375. * ```
  14376. * <!-- ViewRef: outer-0 -->
  14377. * Count: 2
  14378. * <ul>
  14379. * <template view-container-ref></template>
  14380. * <!-- ViewRef: inner-1 --><li>first</li><!-- /ViewRef: inner-1 -->
  14381. * <!-- ViewRef: inner-2 --><li>second</li><!-- /ViewRef: inner-2 -->
  14382. * </ul>
  14383. * <!-- /ViewRef: outer-0 -->
  14384. * ```
  14385. */
  14386. var ViewRef = (function () {
  14387. function ViewRef() {
  14388. }
  14389. Object.defineProperty(ViewRef.prototype, "changeDetectorRef", {
  14390. get: function () { return exceptions_1.unimplemented(); },
  14391. set: function (value) {
  14392. exceptions_1.unimplemented(); // TODO: https://github.com/Microsoft/TypeScript/issues/12
  14393. },
  14394. enumerable: true,
  14395. configurable: true
  14396. });
  14397. return ViewRef;
  14398. })();
  14399. exports.ViewRef = ViewRef;
  14400. var ViewRef_ = (function (_super) {
  14401. __extends(ViewRef_, _super);
  14402. function ViewRef_(_view) {
  14403. _super.call(this);
  14404. this._changeDetectorRef = null;
  14405. this._view = _view;
  14406. }
  14407. Object.defineProperty(ViewRef_.prototype, "render", {
  14408. /**
  14409. * Return `RenderViewRef`
  14410. */
  14411. get: function () { return this._view.render; },
  14412. enumerable: true,
  14413. configurable: true
  14414. });
  14415. Object.defineProperty(ViewRef_.prototype, "renderFragment", {
  14416. /**
  14417. * Return `RenderFragmentRef`
  14418. */
  14419. get: function () { return this._view.renderFragment; },
  14420. enumerable: true,
  14421. configurable: true
  14422. });
  14423. Object.defineProperty(ViewRef_.prototype, "changeDetectorRef", {
  14424. /**
  14425. * Return `ChangeDetectorRef`
  14426. */
  14427. get: function () {
  14428. if (this._changeDetectorRef === null) {
  14429. this._changeDetectorRef = this._view.changeDetector.ref;
  14430. }
  14431. return this._changeDetectorRef;
  14432. },
  14433. enumerable: true,
  14434. configurable: true
  14435. });
  14436. ViewRef_.prototype.setLocal = function (variableName, value) { this._view.setLocal(variableName, value); };
  14437. return ViewRef_;
  14438. })(ViewRef);
  14439. exports.ViewRef_ = ViewRef_;
  14440. /**
  14441. * Represents an Angular ProtoView.
  14442. *
  14443. * A ProtoView is a prototypical {@link ViewRef View} that is the result of Template compilation and
  14444. * is used by Angular to efficiently create an instance of this View based on the compiled Template.
  14445. *
  14446. * Most ProtoViews are created and used internally by Angular and you don't need to know about them,
  14447. * except in advanced use-cases where you compile components yourself via the low-level
  14448. * {@link Compiler#compileInHost} API.
  14449. *
  14450. *
  14451. * ### Example
  14452. *
  14453. * Given this template:
  14454. *
  14455. * ```
  14456. * Count: {{items.length}}
  14457. * <ul>
  14458. * <li *ngFor="var item of items">{{item}}</li>
  14459. * </ul>
  14460. * ```
  14461. *
  14462. * Angular desugars and compiles the template into two ProtoViews:
  14463. *
  14464. * Outer ProtoView:
  14465. * ```
  14466. * Count: {{items.length}}
  14467. * <ul>
  14468. * <template ngFor var-item [ngForOf]="items"></template>
  14469. * </ul>
  14470. * ```
  14471. *
  14472. * Inner ProtoView:
  14473. * ```
  14474. * <li>{{item}}</li>
  14475. * ```
  14476. *
  14477. * Notice that the original template is broken down into two separate ProtoViews.
  14478. */
  14479. var ProtoViewRef = (function () {
  14480. function ProtoViewRef() {
  14481. }
  14482. return ProtoViewRef;
  14483. })();
  14484. exports.ProtoViewRef = ProtoViewRef;
  14485. var ProtoViewRef_ = (function (_super) {
  14486. __extends(ProtoViewRef_, _super);
  14487. function ProtoViewRef_(_protoView) {
  14488. _super.call(this);
  14489. this._protoView = _protoView;
  14490. }
  14491. return ProtoViewRef_;
  14492. })(ProtoViewRef);
  14493. exports.ProtoViewRef_ = ProtoViewRef_;
  14494. /***/ },
  14495. /* 78 */
  14496. /***/ function(module, exports, __webpack_require__) {
  14497. var lang_1 = __webpack_require__(5);
  14498. var CAMEL_CASE_REGEXP = /([A-Z])/g;
  14499. var DASH_CASE_REGEXP = /-([a-z])/g;
  14500. function camelCaseToDashCase(input) {
  14501. return lang_1.StringWrapper.replaceAllMapped(input, CAMEL_CASE_REGEXP, function (m) { return '-' + m[1].toLowerCase(); });
  14502. }
  14503. exports.camelCaseToDashCase = camelCaseToDashCase;
  14504. function dashCaseToCamelCase(input) {
  14505. return lang_1.StringWrapper.replaceAllMapped(input, DASH_CASE_REGEXP, function (m) { return m[1].toUpperCase(); });
  14506. }
  14507. exports.dashCaseToCamelCase = dashCaseToCamelCase;
  14508. /***/ },
  14509. /* 79 */
  14510. /***/ function(module, exports, __webpack_require__) {
  14511. var lang_1 = __webpack_require__(5);
  14512. var exceptions_1 = __webpack_require__(14);
  14513. var ElementBinder = (function () {
  14514. function ElementBinder(index, parent, distanceToParent, protoElementInjector, componentDirective, nestedProtoView) {
  14515. this.index = index;
  14516. this.parent = parent;
  14517. this.distanceToParent = distanceToParent;
  14518. this.protoElementInjector = protoElementInjector;
  14519. this.componentDirective = componentDirective;
  14520. this.nestedProtoView = nestedProtoView;
  14521. if (lang_1.isBlank(index)) {
  14522. throw new exceptions_1.BaseException('null index not allowed.');
  14523. }
  14524. }
  14525. return ElementBinder;
  14526. })();
  14527. exports.ElementBinder = ElementBinder;
  14528. /***/ },
  14529. /* 80 */
  14530. /***/ function(module, exports, __webpack_require__) {
  14531. var __extends = (this && this.__extends) || function (d, b) {
  14532. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  14533. function __() { this.constructor = d; }
  14534. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14535. };
  14536. var lang_1 = __webpack_require__(5);
  14537. var exceptions_1 = __webpack_require__(14);
  14538. var async_1 = __webpack_require__(60);
  14539. var collection_1 = __webpack_require__(12);
  14540. var di_1 = __webpack_require__(6);
  14541. var injector_1 = __webpack_require__(11);
  14542. var provider_1 = __webpack_require__(13);
  14543. var di_2 = __webpack_require__(4);
  14544. /* circular */ var avmModule = __webpack_require__(81);
  14545. var view_container_ref_1 = __webpack_require__(87);
  14546. var element_ref_1 = __webpack_require__(83);
  14547. var template_ref_1 = __webpack_require__(84);
  14548. var directives_1 = __webpack_require__(23);
  14549. var directive_lifecycle_reflector_1 = __webpack_require__(88);
  14550. var change_detection_1 = __webpack_require__(25);
  14551. var query_list_1 = __webpack_require__(90);
  14552. var reflection_1 = __webpack_require__(16);
  14553. var event_config_1 = __webpack_require__(91);
  14554. var pipe_provider_1 = __webpack_require__(73);
  14555. var interfaces_1 = __webpack_require__(89);
  14556. var view_container_ref_2 = __webpack_require__(87);
  14557. var _staticKeys;
  14558. var StaticKeys = (function () {
  14559. function StaticKeys() {
  14560. this.viewManagerId = di_1.Key.get(avmModule.AppViewManager).id;
  14561. this.templateRefId = di_1.Key.get(template_ref_1.TemplateRef).id;
  14562. this.viewContainerId = di_1.Key.get(view_container_ref_1.ViewContainerRef).id;
  14563. this.changeDetectorRefId = di_1.Key.get(change_detection_1.ChangeDetectorRef).id;
  14564. this.elementRefId = di_1.Key.get(element_ref_1.ElementRef).id;
  14565. }
  14566. StaticKeys.instance = function () {
  14567. if (lang_1.isBlank(_staticKeys))
  14568. _staticKeys = new StaticKeys();
  14569. return _staticKeys;
  14570. };
  14571. return StaticKeys;
  14572. })();
  14573. exports.StaticKeys = StaticKeys;
  14574. var TreeNode = (function () {
  14575. function TreeNode(parent) {
  14576. if (lang_1.isPresent(parent)) {
  14577. parent.addChild(this);
  14578. }
  14579. else {
  14580. this._parent = null;
  14581. }
  14582. }
  14583. TreeNode.prototype.addChild = function (child) { child._parent = this; };
  14584. TreeNode.prototype.remove = function () { this._parent = null; };
  14585. Object.defineProperty(TreeNode.prototype, "parent", {
  14586. get: function () { return this._parent; },
  14587. enumerable: true,
  14588. configurable: true
  14589. });
  14590. return TreeNode;
  14591. })();
  14592. exports.TreeNode = TreeNode;
  14593. var DirectiveDependency = (function (_super) {
  14594. __extends(DirectiveDependency, _super);
  14595. function DirectiveDependency(key, optional, lowerBoundVisibility, upperBoundVisibility, properties, attributeName, queryDecorator) {
  14596. _super.call(this, key, optional, lowerBoundVisibility, upperBoundVisibility, properties);
  14597. this.attributeName = attributeName;
  14598. this.queryDecorator = queryDecorator;
  14599. this._verify();
  14600. }
  14601. /** @internal */
  14602. DirectiveDependency.prototype._verify = function () {
  14603. var count = 0;
  14604. if (lang_1.isPresent(this.queryDecorator))
  14605. count++;
  14606. if (lang_1.isPresent(this.attributeName))
  14607. count++;
  14608. if (count > 1)
  14609. throw new exceptions_1.BaseException('A directive injectable can contain only one of the following @Attribute or @Query.');
  14610. };
  14611. DirectiveDependency.createFrom = function (d) {
  14612. return new DirectiveDependency(d.key, d.optional, d.lowerBoundVisibility, d.upperBoundVisibility, d.properties, DirectiveDependency._attributeName(d.properties), DirectiveDependency._query(d.properties));
  14613. };
  14614. /** @internal */
  14615. DirectiveDependency._attributeName = function (properties) {
  14616. var p = properties.find(function (p) { return p instanceof di_2.AttributeMetadata; });
  14617. return lang_1.isPresent(p) ? p.attributeName : null;
  14618. };
  14619. /** @internal */
  14620. DirectiveDependency._query = function (properties) {
  14621. return properties.find(function (p) { return p instanceof di_2.QueryMetadata; });
  14622. };
  14623. return DirectiveDependency;
  14624. })(di_1.Dependency);
  14625. exports.DirectiveDependency = DirectiveDependency;
  14626. var DirectiveProvider = (function (_super) {
  14627. __extends(DirectiveProvider, _super);
  14628. function DirectiveProvider(key, factory, deps, metadata, providers, viewProviders) {
  14629. _super.call(this, key, [new provider_1.ResolvedFactory(factory, deps)], false);
  14630. this.metadata = metadata;
  14631. this.providers = providers;
  14632. this.viewProviders = viewProviders;
  14633. this.callOnDestroy = directive_lifecycle_reflector_1.hasLifecycleHook(interfaces_1.LifecycleHooks.OnDestroy, key.token);
  14634. }
  14635. Object.defineProperty(DirectiveProvider.prototype, "displayName", {
  14636. get: function () { return this.key.displayName; },
  14637. enumerable: true,
  14638. configurable: true
  14639. });
  14640. Object.defineProperty(DirectiveProvider.prototype, "queries", {
  14641. get: function () {
  14642. if (lang_1.isBlank(this.metadata.queries))
  14643. return [];
  14644. var res = [];
  14645. collection_1.StringMapWrapper.forEach(this.metadata.queries, function (meta, fieldName) {
  14646. var setter = reflection_1.reflector.setter(fieldName);
  14647. res.push(new QueryMetadataWithSetter(setter, meta));
  14648. });
  14649. return res;
  14650. },
  14651. enumerable: true,
  14652. configurable: true
  14653. });
  14654. Object.defineProperty(DirectiveProvider.prototype, "eventEmitters", {
  14655. get: function () {
  14656. return lang_1.isPresent(this.metadata) && lang_1.isPresent(this.metadata.outputs) ? this.metadata.outputs :
  14657. [];
  14658. },
  14659. enumerable: true,
  14660. configurable: true
  14661. });
  14662. DirectiveProvider.createFromProvider = function (provider, meta) {
  14663. if (lang_1.isBlank(meta)) {
  14664. meta = new directives_1.DirectiveMetadata();
  14665. }
  14666. var rb = provider_1.resolveProvider(provider);
  14667. var rf = rb.resolvedFactories[0];
  14668. var deps = rf.dependencies.map(DirectiveDependency.createFrom);
  14669. var providers = lang_1.isPresent(meta.providers) ? meta.providers : [];
  14670. var viewBindigs = meta instanceof directives_1.ComponentMetadata && lang_1.isPresent(meta.viewProviders) ?
  14671. meta.viewProviders :
  14672. [];
  14673. return new DirectiveProvider(rb.key, rf.factory, deps, meta, providers, viewBindigs);
  14674. };
  14675. DirectiveProvider.createFromType = function (type, annotation) {
  14676. var provider = new di_1.Provider(type, { useClass: type });
  14677. return DirectiveProvider.createFromProvider(provider, annotation);
  14678. };
  14679. return DirectiveProvider;
  14680. })(provider_1.ResolvedProvider_);
  14681. exports.DirectiveProvider = DirectiveProvider;
  14682. // TODO(rado): benchmark and consider rolling in as ElementInjector fields.
  14683. var PreBuiltObjects = (function () {
  14684. function PreBuiltObjects(viewManager, view, elementRef, templateRef) {
  14685. this.viewManager = viewManager;
  14686. this.view = view;
  14687. this.elementRef = elementRef;
  14688. this.templateRef = templateRef;
  14689. this.nestedView = null;
  14690. }
  14691. return PreBuiltObjects;
  14692. })();
  14693. exports.PreBuiltObjects = PreBuiltObjects;
  14694. var QueryMetadataWithSetter = (function () {
  14695. function QueryMetadataWithSetter(setter, metadata) {
  14696. this.setter = setter;
  14697. this.metadata = metadata;
  14698. }
  14699. return QueryMetadataWithSetter;
  14700. })();
  14701. exports.QueryMetadataWithSetter = QueryMetadataWithSetter;
  14702. var EventEmitterAccessor = (function () {
  14703. function EventEmitterAccessor(eventName, getter) {
  14704. this.eventName = eventName;
  14705. this.getter = getter;
  14706. }
  14707. EventEmitterAccessor.prototype.subscribe = function (view, boundElementIndex, directive) {
  14708. var _this = this;
  14709. var eventEmitter = this.getter(directive);
  14710. return async_1.ObservableWrapper.subscribe(eventEmitter, function (eventObj) { return view.triggerEventHandlers(_this.eventName, eventObj, boundElementIndex); });
  14711. };
  14712. return EventEmitterAccessor;
  14713. })();
  14714. exports.EventEmitterAccessor = EventEmitterAccessor;
  14715. function _createEventEmitterAccessors(bwv) {
  14716. var provider = bwv.provider;
  14717. if (!(provider instanceof DirectiveProvider))
  14718. return [];
  14719. var db = provider;
  14720. return db.eventEmitters.map(function (eventConfig) {
  14721. var parsedEvent = event_config_1.EventConfig.parse(eventConfig);
  14722. return new EventEmitterAccessor(parsedEvent.eventName, reflection_1.reflector.getter(parsedEvent.fieldName));
  14723. });
  14724. }
  14725. function _createProtoQueryRefs(providers) {
  14726. var res = [];
  14727. collection_1.ListWrapper.forEachWithIndex(providers, function (b, i) {
  14728. if (b.provider instanceof DirectiveProvider) {
  14729. var directiveProvider = b.provider;
  14730. // field queries
  14731. var queries = directiveProvider.queries;
  14732. queries.forEach(function (q) { return res.push(new ProtoQueryRef(i, q.setter, q.metadata)); });
  14733. // queries passed into the constructor.
  14734. // TODO: remove this after constructor queries are no longer supported
  14735. var deps = directiveProvider.resolvedFactory.dependencies;
  14736. deps.forEach(function (d) {
  14737. if (lang_1.isPresent(d.queryDecorator))
  14738. res.push(new ProtoQueryRef(i, null, d.queryDecorator));
  14739. });
  14740. }
  14741. });
  14742. return res;
  14743. }
  14744. var ProtoElementInjector = (function () {
  14745. function ProtoElementInjector(parent, index, bwv, distanceToParent, _firstProviderIsComponent, directiveVariableBindings) {
  14746. this.parent = parent;
  14747. this.index = index;
  14748. this.distanceToParent = distanceToParent;
  14749. this.directiveVariableBindings = directiveVariableBindings;
  14750. this._firstProviderIsComponent = _firstProviderIsComponent;
  14751. var length = bwv.length;
  14752. this.protoInjector = new injector_1.ProtoInjector(bwv);
  14753. this.eventEmitterAccessors = collection_1.ListWrapper.createFixedSize(length);
  14754. for (var i = 0; i < length; ++i) {
  14755. this.eventEmitterAccessors[i] = _createEventEmitterAccessors(bwv[i]);
  14756. }
  14757. this.protoQueryRefs = _createProtoQueryRefs(bwv);
  14758. }
  14759. ProtoElementInjector.create = function (parent, index, providers, firstProviderIsComponent, distanceToParent, directiveVariableBindings) {
  14760. var bd = [];
  14761. ProtoElementInjector._createDirectiveProviderWithVisibility(providers, bd, firstProviderIsComponent);
  14762. if (firstProviderIsComponent) {
  14763. ProtoElementInjector._createViewProvidersWithVisibility(providers, bd);
  14764. }
  14765. ProtoElementInjector._createProvidersWithVisibility(providers, bd);
  14766. return new ProtoElementInjector(parent, index, bd, distanceToParent, firstProviderIsComponent, directiveVariableBindings);
  14767. };
  14768. ProtoElementInjector._createDirectiveProviderWithVisibility = function (dirProviders, bd, firstProviderIsComponent) {
  14769. dirProviders.forEach(function (dirProvider) {
  14770. bd.push(ProtoElementInjector._createProviderWithVisibility(firstProviderIsComponent, dirProvider, dirProviders, dirProvider));
  14771. });
  14772. };
  14773. ProtoElementInjector._createProvidersWithVisibility = function (dirProviders, bd) {
  14774. var providersFromAllDirectives = [];
  14775. dirProviders.forEach(function (dirProvider) {
  14776. providersFromAllDirectives =
  14777. collection_1.ListWrapper.concat(providersFromAllDirectives, dirProvider.providers);
  14778. });
  14779. var resolved = di_1.Injector.resolve(providersFromAllDirectives);
  14780. resolved.forEach(function (b) { return bd.push(new injector_1.ProviderWithVisibility(b, injector_1.Visibility.Public)); });
  14781. };
  14782. ProtoElementInjector._createProviderWithVisibility = function (firstProviderIsComponent, dirProvider, dirProviders, provider) {
  14783. var isComponent = firstProviderIsComponent && dirProviders[0] === dirProvider;
  14784. return new injector_1.ProviderWithVisibility(provider, isComponent ? injector_1.Visibility.PublicAndPrivate : injector_1.Visibility.Public);
  14785. };
  14786. ProtoElementInjector._createViewProvidersWithVisibility = function (dirProviders, bd) {
  14787. var resolvedViewProviders = di_1.Injector.resolve(dirProviders[0].viewProviders);
  14788. resolvedViewProviders.forEach(function (b) { return bd.push(new injector_1.ProviderWithVisibility(b, injector_1.Visibility.Private)); });
  14789. };
  14790. ProtoElementInjector.prototype.instantiate = function (parent) {
  14791. return new ElementInjector(this, parent);
  14792. };
  14793. ProtoElementInjector.prototype.directParent = function () { return this.distanceToParent < 2 ? this.parent : null; };
  14794. Object.defineProperty(ProtoElementInjector.prototype, "hasBindings", {
  14795. get: function () { return this.eventEmitterAccessors.length > 0; },
  14796. enumerable: true,
  14797. configurable: true
  14798. });
  14799. ProtoElementInjector.prototype.getProviderAtIndex = function (index) { return this.protoInjector.getProviderAtIndex(index); };
  14800. return ProtoElementInjector;
  14801. })();
  14802. exports.ProtoElementInjector = ProtoElementInjector;
  14803. var _Context = (function () {
  14804. function _Context(element, componentElement, injector) {
  14805. this.element = element;
  14806. this.componentElement = componentElement;
  14807. this.injector = injector;
  14808. }
  14809. return _Context;
  14810. })();
  14811. var ElementInjector = (function (_super) {
  14812. __extends(ElementInjector, _super);
  14813. function ElementInjector(_proto, parent) {
  14814. var _this = this;
  14815. _super.call(this, parent);
  14816. this._preBuiltObjects = null;
  14817. this._proto = _proto;
  14818. this._injector =
  14819. new di_1.Injector(this._proto.protoInjector, null, this, function () { return _this._debugContext(); });
  14820. // we couple ourselves to the injector strategy to avoid polymoprhic calls
  14821. var injectorStrategy = this._injector.internalStrategy;
  14822. this._strategy = injectorStrategy instanceof injector_1.InjectorInlineStrategy ?
  14823. new ElementInjectorInlineStrategy(injectorStrategy, this) :
  14824. new ElementInjectorDynamicStrategy(injectorStrategy, this);
  14825. this.hydrated = false;
  14826. this._queryStrategy = this._buildQueryStrategy();
  14827. }
  14828. ElementInjector.prototype.dehydrate = function () {
  14829. this.hydrated = false;
  14830. this._host = null;
  14831. this._preBuiltObjects = null;
  14832. this._strategy.callOnDestroy();
  14833. this._strategy.dehydrate();
  14834. this._queryStrategy.dehydrate();
  14835. };
  14836. ElementInjector.prototype.hydrate = function (imperativelyCreatedInjector, host, preBuiltObjects) {
  14837. this._host = host;
  14838. this._preBuiltObjects = preBuiltObjects;
  14839. this._reattachInjectors(imperativelyCreatedInjector);
  14840. this._queryStrategy.hydrate();
  14841. this._strategy.hydrate();
  14842. this.hydrated = true;
  14843. };
  14844. ElementInjector.prototype._debugContext = function () {
  14845. var p = this._preBuiltObjects;
  14846. var index = p.elementRef.boundElementIndex - p.view.elementOffset;
  14847. var c = this._preBuiltObjects.view.getDebugContext(index, null);
  14848. return lang_1.isPresent(c) ? new _Context(c.element, c.componentElement, c.injector) : null;
  14849. };
  14850. ElementInjector.prototype._reattachInjectors = function (imperativelyCreatedInjector) {
  14851. // Dynamically-loaded component in the template. Not a root ElementInjector.
  14852. if (lang_1.isPresent(this._parent)) {
  14853. if (lang_1.isPresent(imperativelyCreatedInjector)) {
  14854. // The imperative injector is similar to having an element between
  14855. // the dynamic-loaded component and its parent => no boundaries.
  14856. this._reattachInjector(this._injector, imperativelyCreatedInjector, false);
  14857. this._reattachInjector(imperativelyCreatedInjector, this._parent._injector, false);
  14858. }
  14859. else {
  14860. this._reattachInjector(this._injector, this._parent._injector, false);
  14861. }
  14862. }
  14863. else if (lang_1.isPresent(this._host)) {
  14864. // The imperative injector is similar to having an element between
  14865. // the dynamic-loaded component and its parent => no boundary between
  14866. // the component and imperativelyCreatedInjector.
  14867. // But since it is a root ElementInjector, we need to create a boundary
  14868. // between imperativelyCreatedInjector and _host.
  14869. if (lang_1.isPresent(imperativelyCreatedInjector)) {
  14870. this._reattachInjector(this._injector, imperativelyCreatedInjector, false);
  14871. this._reattachInjector(imperativelyCreatedInjector, this._host._injector, true);
  14872. }
  14873. else {
  14874. this._reattachInjector(this._injector, this._host._injector, true);
  14875. }
  14876. }
  14877. else {
  14878. if (lang_1.isPresent(imperativelyCreatedInjector)) {
  14879. this._reattachInjector(this._injector, imperativelyCreatedInjector, true);
  14880. }
  14881. }
  14882. };
  14883. ElementInjector.prototype._reattachInjector = function (injector, parentInjector, isBoundary) {
  14884. injector.internalStrategy.attach(parentInjector, isBoundary);
  14885. };
  14886. ElementInjector.prototype.hasVariableBinding = function (name) {
  14887. var vb = this._proto.directiveVariableBindings;
  14888. return lang_1.isPresent(vb) && vb.has(name);
  14889. };
  14890. ElementInjector.prototype.getVariableBinding = function (name) {
  14891. var index = this._proto.directiveVariableBindings.get(name);
  14892. return lang_1.isPresent(index) ? this.getDirectiveAtIndex(index) : this.getElementRef();
  14893. };
  14894. ElementInjector.prototype.get = function (token) { return this._injector.get(token); };
  14895. ElementInjector.prototype.hasDirective = function (type) { return lang_1.isPresent(this._injector.getOptional(type)); };
  14896. ElementInjector.prototype.getEventEmitterAccessors = function () { return this._proto.eventEmitterAccessors; };
  14897. ElementInjector.prototype.getDirectiveVariableBindings = function () {
  14898. return this._proto.directiveVariableBindings;
  14899. };
  14900. ElementInjector.prototype.getComponent = function () { return this._strategy.getComponent(); };
  14901. ElementInjector.prototype.getInjector = function () { return this._injector; };
  14902. ElementInjector.prototype.getElementRef = function () { return this._preBuiltObjects.elementRef; };
  14903. ElementInjector.prototype.getViewContainerRef = function () {
  14904. return new view_container_ref_2.ViewContainerRef_(this._preBuiltObjects.viewManager, this.getElementRef());
  14905. };
  14906. ElementInjector.prototype.getNestedView = function () { return this._preBuiltObjects.nestedView; };
  14907. ElementInjector.prototype.getView = function () { return this._preBuiltObjects.view; };
  14908. ElementInjector.prototype.directParent = function () { return this._proto.distanceToParent < 2 ? this.parent : null; };
  14909. ElementInjector.prototype.isComponentKey = function (key) { return this._strategy.isComponentKey(key); };
  14910. ElementInjector.prototype.getDependency = function (injector, provider, dep) {
  14911. var key = dep.key;
  14912. if (provider instanceof DirectiveProvider) {
  14913. var dirDep = dep;
  14914. var dirProvider = provider;
  14915. var staticKeys = StaticKeys.instance();
  14916. if (key.id === staticKeys.viewManagerId)
  14917. return this._preBuiltObjects.viewManager;
  14918. if (lang_1.isPresent(dirDep.attributeName))
  14919. return this._buildAttribute(dirDep);
  14920. if (lang_1.isPresent(dirDep.queryDecorator))
  14921. return this._queryStrategy.findQuery(dirDep.queryDecorator).list;
  14922. if (dirDep.key.id === StaticKeys.instance().changeDetectorRefId) {
  14923. // We provide the component's view change detector to components and
  14924. // the surrounding component's change detector to directives.
  14925. if (dirProvider.metadata instanceof directives_1.ComponentMetadata) {
  14926. var componentView = this._preBuiltObjects.view.getNestedView(this._preBuiltObjects.elementRef.boundElementIndex);
  14927. return componentView.changeDetector.ref;
  14928. }
  14929. else {
  14930. return this._preBuiltObjects.view.changeDetector.ref;
  14931. }
  14932. }
  14933. if (dirDep.key.id === StaticKeys.instance().elementRefId) {
  14934. return this.getElementRef();
  14935. }
  14936. if (dirDep.key.id === StaticKeys.instance().viewContainerId) {
  14937. return this.getViewContainerRef();
  14938. }
  14939. if (dirDep.key.id === StaticKeys.instance().templateRefId) {
  14940. if (lang_1.isBlank(this._preBuiltObjects.templateRef)) {
  14941. if (dirDep.optional) {
  14942. return null;
  14943. }
  14944. throw new di_1.NoProviderError(null, dirDep.key);
  14945. }
  14946. return this._preBuiltObjects.templateRef;
  14947. }
  14948. }
  14949. else if (provider instanceof pipe_provider_1.PipeProvider) {
  14950. if (dep.key.id === StaticKeys.instance().changeDetectorRefId) {
  14951. var componentView = this._preBuiltObjects.view.getNestedView(this._preBuiltObjects.elementRef.boundElementIndex);
  14952. return componentView.changeDetector.ref;
  14953. }
  14954. }
  14955. return injector_1.UNDEFINED;
  14956. };
  14957. ElementInjector.prototype._buildAttribute = function (dep) {
  14958. var attributes = this._proto.attributes;
  14959. if (lang_1.isPresent(attributes) && attributes.has(dep.attributeName)) {
  14960. return attributes.get(dep.attributeName);
  14961. }
  14962. else {
  14963. return null;
  14964. }
  14965. };
  14966. ElementInjector.prototype.addDirectivesMatchingQuery = function (query, list) {
  14967. var templateRef = lang_1.isBlank(this._preBuiltObjects) ? null : this._preBuiltObjects.templateRef;
  14968. if (query.selector === template_ref_1.TemplateRef && lang_1.isPresent(templateRef)) {
  14969. list.push(templateRef);
  14970. }
  14971. this._strategy.addDirectivesMatchingQuery(query, list);
  14972. };
  14973. ElementInjector.prototype._buildQueryStrategy = function () {
  14974. if (this._proto.protoQueryRefs.length === 0) {
  14975. return _emptyQueryStrategy;
  14976. }
  14977. else if (this._proto.protoQueryRefs.length <=
  14978. InlineQueryStrategy.NUMBER_OF_SUPPORTED_QUERIES) {
  14979. return new InlineQueryStrategy(this);
  14980. }
  14981. else {
  14982. return new DynamicQueryStrategy(this);
  14983. }
  14984. };
  14985. ElementInjector.prototype.link = function (parent) { parent.addChild(this); };
  14986. ElementInjector.prototype.unlink = function () { this.remove(); };
  14987. ElementInjector.prototype.getDirectiveAtIndex = function (index) { return this._injector.getAt(index); };
  14988. ElementInjector.prototype.hasInstances = function () { return this._proto.hasBindings && this.hydrated; };
  14989. ElementInjector.prototype.getHost = function () { return this._host; };
  14990. ElementInjector.prototype.getBoundElementIndex = function () { return this._proto.index; };
  14991. ElementInjector.prototype.getRootViewInjectors = function () {
  14992. if (!this.hydrated)
  14993. return [];
  14994. var view = this._preBuiltObjects.view;
  14995. var nestedView = view.getNestedView(view.elementOffset + this.getBoundElementIndex());
  14996. return lang_1.isPresent(nestedView) ? nestedView.rootElementInjectors : [];
  14997. };
  14998. ElementInjector.prototype.ngAfterViewChecked = function () { this._queryStrategy.updateViewQueries(); };
  14999. ElementInjector.prototype.ngAfterContentChecked = function () { this._queryStrategy.updateContentQueries(); };
  15000. ElementInjector.prototype.traverseAndSetQueriesAsDirty = function () {
  15001. var inj = this;
  15002. while (lang_1.isPresent(inj)) {
  15003. inj._setQueriesAsDirty();
  15004. inj = inj.parent;
  15005. }
  15006. };
  15007. ElementInjector.prototype._setQueriesAsDirty = function () {
  15008. this._queryStrategy.setContentQueriesAsDirty();
  15009. if (lang_1.isPresent(this._host))
  15010. this._host._queryStrategy.setViewQueriesAsDirty();
  15011. };
  15012. return ElementInjector;
  15013. })(TreeNode);
  15014. exports.ElementInjector = ElementInjector;
  15015. var _EmptyQueryStrategy = (function () {
  15016. function _EmptyQueryStrategy() {
  15017. }
  15018. _EmptyQueryStrategy.prototype.setContentQueriesAsDirty = function () { };
  15019. _EmptyQueryStrategy.prototype.setViewQueriesAsDirty = function () { };
  15020. _EmptyQueryStrategy.prototype.hydrate = function () { };
  15021. _EmptyQueryStrategy.prototype.dehydrate = function () { };
  15022. _EmptyQueryStrategy.prototype.updateContentQueries = function () { };
  15023. _EmptyQueryStrategy.prototype.updateViewQueries = function () { };
  15024. _EmptyQueryStrategy.prototype.findQuery = function (query) {
  15025. throw new exceptions_1.BaseException("Cannot find query for directive " + query + ".");
  15026. };
  15027. return _EmptyQueryStrategy;
  15028. })();
  15029. var _emptyQueryStrategy = new _EmptyQueryStrategy();
  15030. var InlineQueryStrategy = (function () {
  15031. function InlineQueryStrategy(ei) {
  15032. var protoRefs = ei._proto.protoQueryRefs;
  15033. if (protoRefs.length > 0)
  15034. this.query0 = new QueryRef(protoRefs[0], ei);
  15035. if (protoRefs.length > 1)
  15036. this.query1 = new QueryRef(protoRefs[1], ei);
  15037. if (protoRefs.length > 2)
  15038. this.query2 = new QueryRef(protoRefs[2], ei);
  15039. }
  15040. InlineQueryStrategy.prototype.setContentQueriesAsDirty = function () {
  15041. if (lang_1.isPresent(this.query0) && !this.query0.isViewQuery)
  15042. this.query0.dirty = true;
  15043. if (lang_1.isPresent(this.query1) && !this.query1.isViewQuery)
  15044. this.query1.dirty = true;
  15045. if (lang_1.isPresent(this.query2) && !this.query2.isViewQuery)
  15046. this.query2.dirty = true;
  15047. };
  15048. InlineQueryStrategy.prototype.setViewQueriesAsDirty = function () {
  15049. if (lang_1.isPresent(this.query0) && this.query0.isViewQuery)
  15050. this.query0.dirty = true;
  15051. if (lang_1.isPresent(this.query1) && this.query1.isViewQuery)
  15052. this.query1.dirty = true;
  15053. if (lang_1.isPresent(this.query2) && this.query2.isViewQuery)
  15054. this.query2.dirty = true;
  15055. };
  15056. InlineQueryStrategy.prototype.hydrate = function () {
  15057. if (lang_1.isPresent(this.query0))
  15058. this.query0.hydrate();
  15059. if (lang_1.isPresent(this.query1))
  15060. this.query1.hydrate();
  15061. if (lang_1.isPresent(this.query2))
  15062. this.query2.hydrate();
  15063. };
  15064. InlineQueryStrategy.prototype.dehydrate = function () {
  15065. if (lang_1.isPresent(this.query0))
  15066. this.query0.dehydrate();
  15067. if (lang_1.isPresent(this.query1))
  15068. this.query1.dehydrate();
  15069. if (lang_1.isPresent(this.query2))
  15070. this.query2.dehydrate();
  15071. };
  15072. InlineQueryStrategy.prototype.updateContentQueries = function () {
  15073. if (lang_1.isPresent(this.query0) && !this.query0.isViewQuery) {
  15074. this.query0.update();
  15075. }
  15076. if (lang_1.isPresent(this.query1) && !this.query1.isViewQuery) {
  15077. this.query1.update();
  15078. }
  15079. if (lang_1.isPresent(this.query2) && !this.query2.isViewQuery) {
  15080. this.query2.update();
  15081. }
  15082. };
  15083. InlineQueryStrategy.prototype.updateViewQueries = function () {
  15084. if (lang_1.isPresent(this.query0) && this.query0.isViewQuery) {
  15085. this.query0.update();
  15086. }
  15087. if (lang_1.isPresent(this.query1) && this.query1.isViewQuery) {
  15088. this.query1.update();
  15089. }
  15090. if (lang_1.isPresent(this.query2) && this.query2.isViewQuery) {
  15091. this.query2.update();
  15092. }
  15093. };
  15094. InlineQueryStrategy.prototype.findQuery = function (query) {
  15095. if (lang_1.isPresent(this.query0) && this.query0.protoQueryRef.query === query) {
  15096. return this.query0;
  15097. }
  15098. if (lang_1.isPresent(this.query1) && this.query1.protoQueryRef.query === query) {
  15099. return this.query1;
  15100. }
  15101. if (lang_1.isPresent(this.query2) && this.query2.protoQueryRef.query === query) {
  15102. return this.query2;
  15103. }
  15104. throw new exceptions_1.BaseException("Cannot find query for directive " + query + ".");
  15105. };
  15106. InlineQueryStrategy.NUMBER_OF_SUPPORTED_QUERIES = 3;
  15107. return InlineQueryStrategy;
  15108. })();
  15109. var DynamicQueryStrategy = (function () {
  15110. function DynamicQueryStrategy(ei) {
  15111. this.queries = ei._proto.protoQueryRefs.map(function (p) { return new QueryRef(p, ei); });
  15112. }
  15113. DynamicQueryStrategy.prototype.setContentQueriesAsDirty = function () {
  15114. for (var i = 0; i < this.queries.length; ++i) {
  15115. var q = this.queries[i];
  15116. if (!q.isViewQuery)
  15117. q.dirty = true;
  15118. }
  15119. };
  15120. DynamicQueryStrategy.prototype.setViewQueriesAsDirty = function () {
  15121. for (var i = 0; i < this.queries.length; ++i) {
  15122. var q = this.queries[i];
  15123. if (q.isViewQuery)
  15124. q.dirty = true;
  15125. }
  15126. };
  15127. DynamicQueryStrategy.prototype.hydrate = function () {
  15128. for (var i = 0; i < this.queries.length; ++i) {
  15129. var q = this.queries[i];
  15130. q.hydrate();
  15131. }
  15132. };
  15133. DynamicQueryStrategy.prototype.dehydrate = function () {
  15134. for (var i = 0; i < this.queries.length; ++i) {
  15135. var q = this.queries[i];
  15136. q.dehydrate();
  15137. }
  15138. };
  15139. DynamicQueryStrategy.prototype.updateContentQueries = function () {
  15140. for (var i = 0; i < this.queries.length; ++i) {
  15141. var q = this.queries[i];
  15142. if (!q.isViewQuery) {
  15143. q.update();
  15144. }
  15145. }
  15146. };
  15147. DynamicQueryStrategy.prototype.updateViewQueries = function () {
  15148. for (var i = 0; i < this.queries.length; ++i) {
  15149. var q = this.queries[i];
  15150. if (q.isViewQuery) {
  15151. q.update();
  15152. }
  15153. }
  15154. };
  15155. DynamicQueryStrategy.prototype.findQuery = function (query) {
  15156. for (var i = 0; i < this.queries.length; ++i) {
  15157. var q = this.queries[i];
  15158. if (q.protoQueryRef.query === query) {
  15159. return q;
  15160. }
  15161. }
  15162. throw new exceptions_1.BaseException("Cannot find query for directive " + query + ".");
  15163. };
  15164. return DynamicQueryStrategy;
  15165. })();
  15166. /**
  15167. * Strategy used by the `ElementInjector` when the number of providers is 10 or less.
  15168. * In such a case, inlining fields is beneficial for performances.
  15169. */
  15170. var ElementInjectorInlineStrategy = (function () {
  15171. function ElementInjectorInlineStrategy(injectorStrategy, _ei) {
  15172. this.injectorStrategy = injectorStrategy;
  15173. this._ei = _ei;
  15174. }
  15175. ElementInjectorInlineStrategy.prototype.hydrate = function () {
  15176. var i = this.injectorStrategy;
  15177. var p = i.protoStrategy;
  15178. i.resetConstructionCounter();
  15179. if (p.provider0 instanceof DirectiveProvider && lang_1.isPresent(p.keyId0) && i.obj0 === injector_1.UNDEFINED)
  15180. i.obj0 = i.instantiateProvider(p.provider0, p.visibility0);
  15181. if (p.provider1 instanceof DirectiveProvider && lang_1.isPresent(p.keyId1) && i.obj1 === injector_1.UNDEFINED)
  15182. i.obj1 = i.instantiateProvider(p.provider1, p.visibility1);
  15183. if (p.provider2 instanceof DirectiveProvider && lang_1.isPresent(p.keyId2) && i.obj2 === injector_1.UNDEFINED)
  15184. i.obj2 = i.instantiateProvider(p.provider2, p.visibility2);
  15185. if (p.provider3 instanceof DirectiveProvider && lang_1.isPresent(p.keyId3) && i.obj3 === injector_1.UNDEFINED)
  15186. i.obj3 = i.instantiateProvider(p.provider3, p.visibility3);
  15187. if (p.provider4 instanceof DirectiveProvider && lang_1.isPresent(p.keyId4) && i.obj4 === injector_1.UNDEFINED)
  15188. i.obj4 = i.instantiateProvider(p.provider4, p.visibility4);
  15189. if (p.provider5 instanceof DirectiveProvider && lang_1.isPresent(p.keyId5) && i.obj5 === injector_1.UNDEFINED)
  15190. i.obj5 = i.instantiateProvider(p.provider5, p.visibility5);
  15191. if (p.provider6 instanceof DirectiveProvider && lang_1.isPresent(p.keyId6) && i.obj6 === injector_1.UNDEFINED)
  15192. i.obj6 = i.instantiateProvider(p.provider6, p.visibility6);
  15193. if (p.provider7 instanceof DirectiveProvider && lang_1.isPresent(p.keyId7) && i.obj7 === injector_1.UNDEFINED)
  15194. i.obj7 = i.instantiateProvider(p.provider7, p.visibility7);
  15195. if (p.provider8 instanceof DirectiveProvider && lang_1.isPresent(p.keyId8) && i.obj8 === injector_1.UNDEFINED)
  15196. i.obj8 = i.instantiateProvider(p.provider8, p.visibility8);
  15197. if (p.provider9 instanceof DirectiveProvider && lang_1.isPresent(p.keyId9) && i.obj9 === injector_1.UNDEFINED)
  15198. i.obj9 = i.instantiateProvider(p.provider9, p.visibility9);
  15199. };
  15200. ElementInjectorInlineStrategy.prototype.dehydrate = function () {
  15201. var i = this.injectorStrategy;
  15202. i.obj0 = injector_1.UNDEFINED;
  15203. i.obj1 = injector_1.UNDEFINED;
  15204. i.obj2 = injector_1.UNDEFINED;
  15205. i.obj3 = injector_1.UNDEFINED;
  15206. i.obj4 = injector_1.UNDEFINED;
  15207. i.obj5 = injector_1.UNDEFINED;
  15208. i.obj6 = injector_1.UNDEFINED;
  15209. i.obj7 = injector_1.UNDEFINED;
  15210. i.obj8 = injector_1.UNDEFINED;
  15211. i.obj9 = injector_1.UNDEFINED;
  15212. };
  15213. ElementInjectorInlineStrategy.prototype.callOnDestroy = function () {
  15214. var i = this.injectorStrategy;
  15215. var p = i.protoStrategy;
  15216. if (p.provider0 instanceof DirectiveProvider &&
  15217. p.provider0.callOnDestroy) {
  15218. i.obj0.ngOnDestroy();
  15219. }
  15220. if (p.provider1 instanceof DirectiveProvider &&
  15221. p.provider1.callOnDestroy) {
  15222. i.obj1.ngOnDestroy();
  15223. }
  15224. if (p.provider2 instanceof DirectiveProvider &&
  15225. p.provider2.callOnDestroy) {
  15226. i.obj2.ngOnDestroy();
  15227. }
  15228. if (p.provider3 instanceof DirectiveProvider &&
  15229. p.provider3.callOnDestroy) {
  15230. i.obj3.ngOnDestroy();
  15231. }
  15232. if (p.provider4 instanceof DirectiveProvider &&
  15233. p.provider4.callOnDestroy) {
  15234. i.obj4.ngOnDestroy();
  15235. }
  15236. if (p.provider5 instanceof DirectiveProvider &&
  15237. p.provider5.callOnDestroy) {
  15238. i.obj5.ngOnDestroy();
  15239. }
  15240. if (p.provider6 instanceof DirectiveProvider &&
  15241. p.provider6.callOnDestroy) {
  15242. i.obj6.ngOnDestroy();
  15243. }
  15244. if (p.provider7 instanceof DirectiveProvider &&
  15245. p.provider7.callOnDestroy) {
  15246. i.obj7.ngOnDestroy();
  15247. }
  15248. if (p.provider8 instanceof DirectiveProvider &&
  15249. p.provider8.callOnDestroy) {
  15250. i.obj8.ngOnDestroy();
  15251. }
  15252. if (p.provider9 instanceof DirectiveProvider &&
  15253. p.provider9.callOnDestroy) {
  15254. i.obj9.ngOnDestroy();
  15255. }
  15256. };
  15257. ElementInjectorInlineStrategy.prototype.getComponent = function () { return this.injectorStrategy.obj0; };
  15258. ElementInjectorInlineStrategy.prototype.isComponentKey = function (key) {
  15259. return this._ei._proto._firstProviderIsComponent && lang_1.isPresent(key) &&
  15260. key.id === this.injectorStrategy.protoStrategy.keyId0;
  15261. };
  15262. ElementInjectorInlineStrategy.prototype.addDirectivesMatchingQuery = function (query, list) {
  15263. var i = this.injectorStrategy;
  15264. var p = i.protoStrategy;
  15265. if (lang_1.isPresent(p.provider0) && p.provider0.key.token === query.selector) {
  15266. if (i.obj0 === injector_1.UNDEFINED)
  15267. i.obj0 = i.instantiateProvider(p.provider0, p.visibility0);
  15268. list.push(i.obj0);
  15269. }
  15270. if (lang_1.isPresent(p.provider1) && p.provider1.key.token === query.selector) {
  15271. if (i.obj1 === injector_1.UNDEFINED)
  15272. i.obj1 = i.instantiateProvider(p.provider1, p.visibility1);
  15273. list.push(i.obj1);
  15274. }
  15275. if (lang_1.isPresent(p.provider2) && p.provider2.key.token === query.selector) {
  15276. if (i.obj2 === injector_1.UNDEFINED)
  15277. i.obj2 = i.instantiateProvider(p.provider2, p.visibility2);
  15278. list.push(i.obj2);
  15279. }
  15280. if (lang_1.isPresent(p.provider3) && p.provider3.key.token === query.selector) {
  15281. if (i.obj3 === injector_1.UNDEFINED)
  15282. i.obj3 = i.instantiateProvider(p.provider3, p.visibility3);
  15283. list.push(i.obj3);
  15284. }
  15285. if (lang_1.isPresent(p.provider4) && p.provider4.key.token === query.selector) {
  15286. if (i.obj4 === injector_1.UNDEFINED)
  15287. i.obj4 = i.instantiateProvider(p.provider4, p.visibility4);
  15288. list.push(i.obj4);
  15289. }
  15290. if (lang_1.isPresent(p.provider5) && p.provider5.key.token === query.selector) {
  15291. if (i.obj5 === injector_1.UNDEFINED)
  15292. i.obj5 = i.instantiateProvider(p.provider5, p.visibility5);
  15293. list.push(i.obj5);
  15294. }
  15295. if (lang_1.isPresent(p.provider6) && p.provider6.key.token === query.selector) {
  15296. if (i.obj6 === injector_1.UNDEFINED)
  15297. i.obj6 = i.instantiateProvider(p.provider6, p.visibility6);
  15298. list.push(i.obj6);
  15299. }
  15300. if (lang_1.isPresent(p.provider7) && p.provider7.key.token === query.selector) {
  15301. if (i.obj7 === injector_1.UNDEFINED)
  15302. i.obj7 = i.instantiateProvider(p.provider7, p.visibility7);
  15303. list.push(i.obj7);
  15304. }
  15305. if (lang_1.isPresent(p.provider8) && p.provider8.key.token === query.selector) {
  15306. if (i.obj8 === injector_1.UNDEFINED)
  15307. i.obj8 = i.instantiateProvider(p.provider8, p.visibility8);
  15308. list.push(i.obj8);
  15309. }
  15310. if (lang_1.isPresent(p.provider9) && p.provider9.key.token === query.selector) {
  15311. if (i.obj9 === injector_1.UNDEFINED)
  15312. i.obj9 = i.instantiateProvider(p.provider9, p.visibility9);
  15313. list.push(i.obj9);
  15314. }
  15315. };
  15316. return ElementInjectorInlineStrategy;
  15317. })();
  15318. /**
  15319. * Strategy used by the `ElementInjector` when the number of bindings is 11 or more.
  15320. * In such a case, there are too many fields to inline (see ElementInjectorInlineStrategy).
  15321. */
  15322. var ElementInjectorDynamicStrategy = (function () {
  15323. function ElementInjectorDynamicStrategy(injectorStrategy, _ei) {
  15324. this.injectorStrategy = injectorStrategy;
  15325. this._ei = _ei;
  15326. }
  15327. ElementInjectorDynamicStrategy.prototype.hydrate = function () {
  15328. var inj = this.injectorStrategy;
  15329. var p = inj.protoStrategy;
  15330. inj.resetConstructionCounter();
  15331. for (var i = 0; i < p.keyIds.length; i++) {
  15332. if (p.providers[i] instanceof DirectiveProvider && lang_1.isPresent(p.keyIds[i]) &&
  15333. inj.objs[i] === injector_1.UNDEFINED) {
  15334. inj.objs[i] = inj.instantiateProvider(p.providers[i], p.visibilities[i]);
  15335. }
  15336. }
  15337. };
  15338. ElementInjectorDynamicStrategy.prototype.dehydrate = function () {
  15339. var inj = this.injectorStrategy;
  15340. collection_1.ListWrapper.fill(inj.objs, injector_1.UNDEFINED);
  15341. };
  15342. ElementInjectorDynamicStrategy.prototype.callOnDestroy = function () {
  15343. var ist = this.injectorStrategy;
  15344. var p = ist.protoStrategy;
  15345. for (var i = 0; i < p.providers.length; i++) {
  15346. if (p.providers[i] instanceof DirectiveProvider &&
  15347. p.providers[i].callOnDestroy) {
  15348. ist.objs[i].ngOnDestroy();
  15349. }
  15350. }
  15351. };
  15352. ElementInjectorDynamicStrategy.prototype.getComponent = function () { return this.injectorStrategy.objs[0]; };
  15353. ElementInjectorDynamicStrategy.prototype.isComponentKey = function (key) {
  15354. var p = this.injectorStrategy.protoStrategy;
  15355. return this._ei._proto._firstProviderIsComponent && lang_1.isPresent(key) && key.id === p.keyIds[0];
  15356. };
  15357. ElementInjectorDynamicStrategy.prototype.addDirectivesMatchingQuery = function (query, list) {
  15358. var ist = this.injectorStrategy;
  15359. var p = ist.protoStrategy;
  15360. for (var i = 0; i < p.providers.length; i++) {
  15361. if (p.providers[i].key.token === query.selector) {
  15362. if (ist.objs[i] === injector_1.UNDEFINED) {
  15363. ist.objs[i] = ist.instantiateProvider(p.providers[i], p.visibilities[i]);
  15364. }
  15365. list.push(ist.objs[i]);
  15366. }
  15367. }
  15368. };
  15369. return ElementInjectorDynamicStrategy;
  15370. })();
  15371. var ProtoQueryRef = (function () {
  15372. function ProtoQueryRef(dirIndex, setter, query) {
  15373. this.dirIndex = dirIndex;
  15374. this.setter = setter;
  15375. this.query = query;
  15376. }
  15377. Object.defineProperty(ProtoQueryRef.prototype, "usesPropertySyntax", {
  15378. get: function () { return lang_1.isPresent(this.setter); },
  15379. enumerable: true,
  15380. configurable: true
  15381. });
  15382. return ProtoQueryRef;
  15383. })();
  15384. exports.ProtoQueryRef = ProtoQueryRef;
  15385. var QueryRef = (function () {
  15386. function QueryRef(protoQueryRef, originator) {
  15387. this.protoQueryRef = protoQueryRef;
  15388. this.originator = originator;
  15389. }
  15390. Object.defineProperty(QueryRef.prototype, "isViewQuery", {
  15391. get: function () { return this.protoQueryRef.query.isViewQuery; },
  15392. enumerable: true,
  15393. configurable: true
  15394. });
  15395. QueryRef.prototype.update = function () {
  15396. if (!this.dirty)
  15397. return;
  15398. this._update();
  15399. this.dirty = false;
  15400. // TODO delete the check once only field queries are supported
  15401. if (this.protoQueryRef.usesPropertySyntax) {
  15402. var dir = this.originator.getDirectiveAtIndex(this.protoQueryRef.dirIndex);
  15403. if (this.protoQueryRef.query.first) {
  15404. this.protoQueryRef.setter(dir, this.list.length > 0 ? this.list.first : null);
  15405. }
  15406. else {
  15407. this.protoQueryRef.setter(dir, this.list);
  15408. }
  15409. }
  15410. this.list.notifyOnChanges();
  15411. };
  15412. QueryRef.prototype._update = function () {
  15413. var aggregator = [];
  15414. if (this.protoQueryRef.query.isViewQuery) {
  15415. var view = this.originator.getView();
  15416. // intentionally skipping originator for view queries.
  15417. var nestedView = view.getNestedView(view.elementOffset + this.originator.getBoundElementIndex());
  15418. if (lang_1.isPresent(nestedView))
  15419. this._visitView(nestedView, aggregator);
  15420. }
  15421. else {
  15422. this._visit(this.originator, aggregator);
  15423. }
  15424. this.list.reset(aggregator);
  15425. };
  15426. ;
  15427. QueryRef.prototype._visit = function (inj, aggregator) {
  15428. var view = inj.getView();
  15429. var startIdx = view.elementOffset + inj._proto.index;
  15430. for (var i = startIdx; i < view.elementOffset + view.ownBindersCount; i++) {
  15431. var curInj = view.elementInjectors[i];
  15432. if (lang_1.isBlank(curInj))
  15433. continue;
  15434. // The first injector after inj, that is outside the subtree rooted at
  15435. // inj has to have a null parent or a parent that is an ancestor of inj.
  15436. if (i > startIdx && (lang_1.isBlank(curInj) || lang_1.isBlank(curInj.parent) ||
  15437. view.elementOffset + curInj.parent._proto.index < startIdx)) {
  15438. break;
  15439. }
  15440. if (!this.protoQueryRef.query.descendants &&
  15441. !(curInj.parent == this.originator || curInj == this.originator))
  15442. continue;
  15443. // We visit the view container(VC) views right after the injector that contains
  15444. // the VC. Theoretically, that might not be the right order if there are
  15445. // child injectors of said injector. Not clear whether if such case can
  15446. // even be constructed with the current apis.
  15447. this._visitInjector(curInj, aggregator);
  15448. var vc = view.viewContainers[i];
  15449. if (lang_1.isPresent(vc))
  15450. this._visitViewContainer(vc, aggregator);
  15451. }
  15452. };
  15453. QueryRef.prototype._visitInjector = function (inj, aggregator) {
  15454. if (this.protoQueryRef.query.isVarBindingQuery) {
  15455. this._aggregateVariableBinding(inj, aggregator);
  15456. }
  15457. else {
  15458. this._aggregateDirective(inj, aggregator);
  15459. }
  15460. };
  15461. QueryRef.prototype._visitViewContainer = function (vc, aggregator) {
  15462. for (var j = 0; j < vc.views.length; j++) {
  15463. this._visitView(vc.views[j], aggregator);
  15464. }
  15465. };
  15466. QueryRef.prototype._visitView = function (view, aggregator) {
  15467. for (var i = view.elementOffset; i < view.elementOffset + view.ownBindersCount; i++) {
  15468. var inj = view.elementInjectors[i];
  15469. if (lang_1.isBlank(inj))
  15470. continue;
  15471. this._visitInjector(inj, aggregator);
  15472. var vc = view.viewContainers[i];
  15473. if (lang_1.isPresent(vc))
  15474. this._visitViewContainer(vc, aggregator);
  15475. }
  15476. };
  15477. QueryRef.prototype._aggregateVariableBinding = function (inj, aggregator) {
  15478. var vb = this.protoQueryRef.query.varBindings;
  15479. for (var i = 0; i < vb.length; ++i) {
  15480. if (inj.hasVariableBinding(vb[i])) {
  15481. aggregator.push(inj.getVariableBinding(vb[i]));
  15482. }
  15483. }
  15484. };
  15485. QueryRef.prototype._aggregateDirective = function (inj, aggregator) {
  15486. inj.addDirectivesMatchingQuery(this.protoQueryRef.query, aggregator);
  15487. };
  15488. QueryRef.prototype.dehydrate = function () { this.list = null; };
  15489. QueryRef.prototype.hydrate = function () {
  15490. this.list = new query_list_1.QueryList();
  15491. this.dirty = true;
  15492. };
  15493. return QueryRef;
  15494. })();
  15495. exports.QueryRef = QueryRef;
  15496. /***/ },
  15497. /* 81 */
  15498. /***/ function(module, exports, __webpack_require__) {
  15499. var __extends = (this && this.__extends) || function (d, b) {
  15500. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  15501. function __() { this.constructor = d; }
  15502. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15503. };
  15504. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  15505. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  15506. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  15507. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  15508. return c > 3 && r && Object.defineProperty(target, key, r), r;
  15509. };
  15510. var __metadata = (this && this.__metadata) || function (k, v) {
  15511. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  15512. };
  15513. var __param = (this && this.__param) || function (paramIndex, decorator) {
  15514. return function (target, key) { decorator(target, key, paramIndex); }
  15515. };
  15516. var di_1 = __webpack_require__(6);
  15517. var lang_1 = __webpack_require__(5);
  15518. var exceptions_1 = __webpack_require__(14);
  15519. var viewModule = __webpack_require__(76);
  15520. var view_ref_1 = __webpack_require__(77);
  15521. var api_1 = __webpack_require__(72);
  15522. var view_manager_utils_1 = __webpack_require__(82);
  15523. var view_pool_1 = __webpack_require__(85);
  15524. var view_listener_1 = __webpack_require__(86);
  15525. var profile_1 = __webpack_require__(45);
  15526. var proto_view_factory_1 = __webpack_require__(71);
  15527. /**
  15528. * Service exposing low level API for creating, moving and destroying Views.
  15529. *
  15530. * Most applications should use higher-level abstractions like {@link DynamicComponentLoader} and
  15531. * {@link ViewContainerRef} instead.
  15532. */
  15533. var AppViewManager = (function () {
  15534. function AppViewManager() {
  15535. }
  15536. /**
  15537. * Returns the {@link ElementRef} that makes up the specified Host View.
  15538. */
  15539. AppViewManager.prototype.getHostElement = function (hostViewRef) {
  15540. var hostView = view_ref_1.internalView(hostViewRef);
  15541. if (hostView.proto.type !== viewModule.ViewType.HOST) {
  15542. throw new exceptions_1.BaseException('This operation is only allowed on host views');
  15543. }
  15544. return hostView.elementRefs[hostView.elementOffset];
  15545. };
  15546. return AppViewManager;
  15547. })();
  15548. exports.AppViewManager = AppViewManager;
  15549. var AppViewManager_ = (function (_super) {
  15550. __extends(AppViewManager_, _super);
  15551. function AppViewManager_(_viewPool, _viewListener, _utils, _renderer, _protoViewFactory) {
  15552. _super.call(this);
  15553. this._viewPool = _viewPool;
  15554. this._viewListener = _viewListener;
  15555. this._utils = _utils;
  15556. this._renderer = _renderer;
  15557. /** @internal */
  15558. this._createRootHostViewScope = profile_1.wtfCreateScope('AppViewManager#createRootHostView()');
  15559. /** @internal */
  15560. this._destroyRootHostViewScope = profile_1.wtfCreateScope('AppViewManager#destroyRootHostView()');
  15561. /** @internal */
  15562. this._createEmbeddedViewInContainerScope = profile_1.wtfCreateScope('AppViewManager#createEmbeddedViewInContainer()');
  15563. /** @internal */
  15564. this._createHostViewInContainerScope = profile_1.wtfCreateScope('AppViewManager#createHostViewInContainer()');
  15565. /** @internal */
  15566. this._destroyViewInContainerScope = profile_1.wtfCreateScope('AppViewMananger#destroyViewInContainer()');
  15567. /** @internal */
  15568. this._attachViewInContainerScope = profile_1.wtfCreateScope('AppViewMananger#attachViewInContainer()');
  15569. /** @internal */
  15570. this._detachViewInContainerScope = profile_1.wtfCreateScope('AppViewMananger#detachViewInContainer()');
  15571. this._protoViewFactory = _protoViewFactory;
  15572. }
  15573. AppViewManager_.prototype.getViewContainer = function (location) {
  15574. var hostView = view_ref_1.internalView(location.parentView);
  15575. return hostView.elementInjectors[location.boundElementIndex]
  15576. .getViewContainerRef();
  15577. };
  15578. AppViewManager_.prototype.getNamedElementInComponentView = function (hostLocation, variableName) {
  15579. var hostView = view_ref_1.internalView(hostLocation.parentView);
  15580. var boundElementIndex = hostLocation.boundElementIndex;
  15581. var componentView = hostView.getNestedView(boundElementIndex);
  15582. if (lang_1.isBlank(componentView)) {
  15583. throw new exceptions_1.BaseException("There is no component directive at element " + boundElementIndex);
  15584. }
  15585. var binderIdx = componentView.proto.variableLocations.get(variableName);
  15586. if (lang_1.isBlank(binderIdx)) {
  15587. throw new exceptions_1.BaseException("Could not find variable " + variableName);
  15588. }
  15589. return componentView.elementRefs[componentView.elementOffset + binderIdx];
  15590. };
  15591. AppViewManager_.prototype.getComponent = function (hostLocation) {
  15592. var hostView = view_ref_1.internalView(hostLocation.parentView);
  15593. var boundElementIndex = hostLocation.boundElementIndex;
  15594. return this._utils.getComponentInstance(hostView, boundElementIndex);
  15595. };
  15596. AppViewManager_.prototype.createRootHostView = function (hostProtoViewRef, overrideSelector, injector) {
  15597. var s = this._createRootHostViewScope();
  15598. var hostProtoView = view_ref_1.internalProtoView(hostProtoViewRef);
  15599. this._protoViewFactory.initializeProtoViewIfNeeded(hostProtoView);
  15600. var hostElementSelector = overrideSelector;
  15601. if (lang_1.isBlank(hostElementSelector)) {
  15602. hostElementSelector = hostProtoView.elementBinders[0].componentDirective.metadata.selector;
  15603. }
  15604. var renderViewWithFragments = this._renderer.createRootHostView(hostProtoView.render, hostProtoView.mergeInfo.embeddedViewCount + 1, hostElementSelector);
  15605. var hostView = this._createMainView(hostProtoView, renderViewWithFragments);
  15606. this._renderer.hydrateView(hostView.render);
  15607. this._utils.hydrateRootHostView(hostView, injector);
  15608. return profile_1.wtfLeave(s, hostView.ref);
  15609. };
  15610. AppViewManager_.prototype.destroyRootHostView = function (hostViewRef) {
  15611. // Note: Don't put the hostView into the view pool
  15612. // as it is depending on the element for which it was created.
  15613. var s = this._destroyRootHostViewScope();
  15614. var hostView = view_ref_1.internalView(hostViewRef);
  15615. this._renderer.detachFragment(hostView.renderFragment);
  15616. this._renderer.dehydrateView(hostView.render);
  15617. this._viewDehydrateRecurse(hostView);
  15618. this._viewListener.onViewDestroyed(hostView);
  15619. this._renderer.destroyView(hostView.render);
  15620. profile_1.wtfLeave(s);
  15621. };
  15622. AppViewManager_.prototype.createEmbeddedViewInContainer = function (viewContainerLocation, index, templateRef) {
  15623. var s = this._createEmbeddedViewInContainerScope();
  15624. var protoView = view_ref_1.internalProtoView(templateRef.protoViewRef);
  15625. if (protoView.type !== viewModule.ViewType.EMBEDDED) {
  15626. throw new exceptions_1.BaseException('This method can only be called with embedded ProtoViews!');
  15627. }
  15628. this._protoViewFactory.initializeProtoViewIfNeeded(protoView);
  15629. return profile_1.wtfLeave(s, this._createViewInContainer(viewContainerLocation, index, protoView, templateRef.elementRef, null));
  15630. };
  15631. AppViewManager_.prototype.createHostViewInContainer = function (viewContainerLocation, index, protoViewRef, imperativelyCreatedInjector) {
  15632. var s = this._createHostViewInContainerScope();
  15633. var protoView = view_ref_1.internalProtoView(protoViewRef);
  15634. if (protoView.type !== viewModule.ViewType.HOST) {
  15635. throw new exceptions_1.BaseException('This method can only be called with host ProtoViews!');
  15636. }
  15637. this._protoViewFactory.initializeProtoViewIfNeeded(protoView);
  15638. return profile_1.wtfLeave(s, this._createViewInContainer(viewContainerLocation, index, protoView, viewContainerLocation, imperativelyCreatedInjector));
  15639. };
  15640. /**
  15641. *
  15642. * See {@link AppViewManager#destroyViewInContainer}.
  15643. * @internal
  15644. */
  15645. AppViewManager_.prototype._createViewInContainer = function (viewContainerLocation, index, protoView, context, imperativelyCreatedInjector) {
  15646. var parentView = view_ref_1.internalView(viewContainerLocation.parentView);
  15647. var boundElementIndex = viewContainerLocation.boundElementIndex;
  15648. var contextView = view_ref_1.internalView(context.parentView);
  15649. var contextBoundElementIndex = context.boundElementIndex;
  15650. var embeddedFragmentView = contextView.getNestedView(contextBoundElementIndex);
  15651. var view;
  15652. if (protoView.type === viewModule.ViewType.EMBEDDED && lang_1.isPresent(embeddedFragmentView) &&
  15653. !embeddedFragmentView.hydrated()) {
  15654. // Case 1: instantiate the first view of a template that has been merged into a parent
  15655. view = embeddedFragmentView;
  15656. this._attachRenderView(parentView, boundElementIndex, index, view);
  15657. }
  15658. else {
  15659. // Case 2: instantiate another copy of the template or a host ProtoView.
  15660. // This is a separate case
  15661. // as we only inline one copy of the template into the parent view.
  15662. view = this._createPooledView(protoView);
  15663. this._attachRenderView(parentView, boundElementIndex, index, view);
  15664. this._renderer.hydrateView(view.render);
  15665. }
  15666. this._utils.attachViewInContainer(parentView, boundElementIndex, contextView, contextBoundElementIndex, index, view);
  15667. try {
  15668. this._utils.hydrateViewInContainer(parentView, boundElementIndex, contextView, contextBoundElementIndex, index, imperativelyCreatedInjector);
  15669. }
  15670. catch (e) {
  15671. this._utils.detachViewInContainer(parentView, boundElementIndex, index);
  15672. throw e;
  15673. }
  15674. return view.ref;
  15675. };
  15676. /** @internal */
  15677. AppViewManager_.prototype._attachRenderView = function (parentView, boundElementIndex, index, view) {
  15678. var elementRef = parentView.elementRefs[boundElementIndex];
  15679. if (index === 0) {
  15680. this._renderer.attachFragmentAfterElement(elementRef, view.renderFragment);
  15681. }
  15682. else {
  15683. var prevView = parentView.viewContainers[boundElementIndex].views[index - 1];
  15684. this._renderer.attachFragmentAfterFragment(prevView.renderFragment, view.renderFragment);
  15685. }
  15686. };
  15687. AppViewManager_.prototype.destroyViewInContainer = function (viewContainerLocation, index) {
  15688. var s = this._destroyViewInContainerScope();
  15689. var parentView = view_ref_1.internalView(viewContainerLocation.parentView);
  15690. var boundElementIndex = viewContainerLocation.boundElementIndex;
  15691. this._destroyViewInContainer(parentView, boundElementIndex, index);
  15692. profile_1.wtfLeave(s);
  15693. };
  15694. // TODO(i): refactor detachViewInContainer+attachViewInContainer to moveViewInContainer
  15695. AppViewManager_.prototype.attachViewInContainer = function (viewContainerLocation, index, viewRef) {
  15696. var s = this._attachViewInContainerScope();
  15697. var view = view_ref_1.internalView(viewRef);
  15698. var parentView = view_ref_1.internalView(viewContainerLocation.parentView);
  15699. var boundElementIndex = viewContainerLocation.boundElementIndex;
  15700. // TODO(tbosch): the public methods attachViewInContainer/detachViewInContainer
  15701. // are used for moving elements without the same container.
  15702. // We will change this into an atomic `move` operation, which should preserve the
  15703. // previous parent injector (see https://github.com/angular/angular/issues/1377).
  15704. // Right now we are destroying any special
  15705. // context view that might have been used.
  15706. this._utils.attachViewInContainer(parentView, boundElementIndex, null, null, index, view);
  15707. this._attachRenderView(parentView, boundElementIndex, index, view);
  15708. return profile_1.wtfLeave(s, viewRef);
  15709. };
  15710. // TODO(i): refactor detachViewInContainer+attachViewInContainer to moveViewInContainer
  15711. AppViewManager_.prototype.detachViewInContainer = function (viewContainerLocation, index) {
  15712. var s = this._detachViewInContainerScope();
  15713. var parentView = view_ref_1.internalView(viewContainerLocation.parentView);
  15714. var boundElementIndex = viewContainerLocation.boundElementIndex;
  15715. var viewContainer = parentView.viewContainers[boundElementIndex];
  15716. var view = viewContainer.views[index];
  15717. this._utils.detachViewInContainer(parentView, boundElementIndex, index);
  15718. this._renderer.detachFragment(view.renderFragment);
  15719. return profile_1.wtfLeave(s, view.ref);
  15720. };
  15721. /** @internal */
  15722. AppViewManager_.prototype._createMainView = function (protoView, renderViewWithFragments) {
  15723. var mergedParentView = this._utils.createView(protoView, renderViewWithFragments, this, this._renderer);
  15724. this._renderer.setEventDispatcher(mergedParentView.render, mergedParentView);
  15725. this._viewListener.onViewCreated(mergedParentView);
  15726. return mergedParentView;
  15727. };
  15728. /** @internal */
  15729. AppViewManager_.prototype._createPooledView = function (protoView) {
  15730. var view = this._viewPool.getView(protoView);
  15731. if (lang_1.isBlank(view)) {
  15732. view = this._createMainView(protoView, this._renderer.createView(protoView.render, protoView.mergeInfo.embeddedViewCount + 1));
  15733. }
  15734. return view;
  15735. };
  15736. /** @internal */
  15737. AppViewManager_.prototype._destroyPooledView = function (view) {
  15738. var wasReturned = this._viewPool.returnView(view);
  15739. if (!wasReturned) {
  15740. this._viewListener.onViewDestroyed(view);
  15741. this._renderer.destroyView(view.render);
  15742. }
  15743. };
  15744. /** @internal */
  15745. AppViewManager_.prototype._destroyViewInContainer = function (parentView, boundElementIndex, index) {
  15746. var viewContainer = parentView.viewContainers[boundElementIndex];
  15747. var view = viewContainer.views[index];
  15748. this._viewDehydrateRecurse(view);
  15749. this._utils.detachViewInContainer(parentView, boundElementIndex, index);
  15750. if (view.viewOffset > 0) {
  15751. // Case 1: a view that is part of another view.
  15752. // Just detach the fragment
  15753. this._renderer.detachFragment(view.renderFragment);
  15754. }
  15755. else {
  15756. // Case 2: a view that is not part of another view.
  15757. // dehydrate and destroy it.
  15758. this._renderer.dehydrateView(view.render);
  15759. this._renderer.detachFragment(view.renderFragment);
  15760. this._destroyPooledView(view);
  15761. }
  15762. };
  15763. /** @internal */
  15764. AppViewManager_.prototype._viewDehydrateRecurse = function (view) {
  15765. if (view.hydrated()) {
  15766. this._utils.dehydrateView(view);
  15767. }
  15768. var viewContainers = view.viewContainers;
  15769. var startViewOffset = view.viewOffset;
  15770. var endViewOffset = view.viewOffset + view.proto.mergeInfo.viewCount - 1;
  15771. var elementOffset = view.elementOffset;
  15772. for (var viewIdx = startViewOffset; viewIdx <= endViewOffset; viewIdx++) {
  15773. var currView = view.views[viewIdx];
  15774. for (var binderIdx = 0; binderIdx < currView.proto.elementBinders.length; binderIdx++, elementOffset++) {
  15775. var vc = viewContainers[elementOffset];
  15776. if (lang_1.isPresent(vc)) {
  15777. for (var j = vc.views.length - 1; j >= 0; j--) {
  15778. this._destroyViewInContainer(currView, elementOffset, j);
  15779. }
  15780. }
  15781. }
  15782. }
  15783. };
  15784. AppViewManager_ = __decorate([
  15785. di_1.Injectable(),
  15786. __param(4, di_1.Inject(di_1.forwardRef(function () { return proto_view_factory_1.ProtoViewFactory; }))),
  15787. __metadata('design:paramtypes', [view_pool_1.AppViewPool, view_listener_1.AppViewListener, view_manager_utils_1.AppViewManagerUtils, api_1.Renderer, Object])
  15788. ], AppViewManager_);
  15789. return AppViewManager_;
  15790. })(AppViewManager);
  15791. exports.AppViewManager_ = AppViewManager_;
  15792. /***/ },
  15793. /* 82 */
  15794. /***/ function(module, exports, __webpack_require__) {
  15795. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  15796. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  15797. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  15798. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  15799. return c > 3 && r && Object.defineProperty(target, key, r), r;
  15800. };
  15801. var __metadata = (this && this.__metadata) || function (k, v) {
  15802. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  15803. };
  15804. var di_1 = __webpack_require__(6);
  15805. var collection_1 = __webpack_require__(12);
  15806. var eli = __webpack_require__(80);
  15807. var lang_1 = __webpack_require__(5);
  15808. var viewModule = __webpack_require__(76);
  15809. var element_ref_1 = __webpack_require__(83);
  15810. var template_ref_1 = __webpack_require__(84);
  15811. var pipes_1 = __webpack_require__(74);
  15812. var AppViewManagerUtils = (function () {
  15813. function AppViewManagerUtils() {
  15814. }
  15815. AppViewManagerUtils.prototype.getComponentInstance = function (parentView, boundElementIndex) {
  15816. var eli = parentView.elementInjectors[boundElementIndex];
  15817. return eli.getComponent();
  15818. };
  15819. AppViewManagerUtils.prototype.createView = function (mergedParentViewProto, renderViewWithFragments, viewManager, renderer) {
  15820. var renderFragments = renderViewWithFragments.fragmentRefs;
  15821. var renderView = renderViewWithFragments.viewRef;
  15822. var elementCount = mergedParentViewProto.mergeInfo.elementCount;
  15823. var viewCount = mergedParentViewProto.mergeInfo.viewCount;
  15824. var elementRefs = collection_1.ListWrapper.createFixedSize(elementCount);
  15825. var viewContainers = collection_1.ListWrapper.createFixedSize(elementCount);
  15826. var preBuiltObjects = collection_1.ListWrapper.createFixedSize(elementCount);
  15827. var elementInjectors = collection_1.ListWrapper.createFixedSize(elementCount);
  15828. var views = collection_1.ListWrapper.createFixedSize(viewCount);
  15829. var elementOffset = 0;
  15830. var textOffset = 0;
  15831. var fragmentIdx = 0;
  15832. var containerElementIndicesByViewIndex = collection_1.ListWrapper.createFixedSize(viewCount);
  15833. for (var viewOffset = 0; viewOffset < viewCount; viewOffset++) {
  15834. var containerElementIndex = containerElementIndicesByViewIndex[viewOffset];
  15835. var containerElementInjector = lang_1.isPresent(containerElementIndex) ? elementInjectors[containerElementIndex] : null;
  15836. var parentView = lang_1.isPresent(containerElementInjector) ? preBuiltObjects[containerElementIndex].view : null;
  15837. var protoView = lang_1.isPresent(containerElementIndex) ?
  15838. parentView.proto.elementBinders[containerElementIndex - parentView.elementOffset]
  15839. .nestedProtoView :
  15840. mergedParentViewProto;
  15841. var renderFragment = null;
  15842. if (viewOffset === 0 || protoView.type === viewModule.ViewType.EMBEDDED) {
  15843. renderFragment = renderFragments[fragmentIdx++];
  15844. }
  15845. var currentView = new viewModule.AppView(renderer, protoView, viewOffset, elementOffset, textOffset, protoView.protoLocals, renderView, renderFragment, containerElementInjector);
  15846. views[viewOffset] = currentView;
  15847. if (lang_1.isPresent(containerElementIndex)) {
  15848. preBuiltObjects[containerElementIndex].nestedView = currentView;
  15849. }
  15850. var rootElementInjectors = [];
  15851. var nestedViewOffset = viewOffset + 1;
  15852. for (var binderIdx = 0; binderIdx < protoView.elementBinders.length; binderIdx++) {
  15853. var binder = protoView.elementBinders[binderIdx];
  15854. var boundElementIndex = elementOffset + binderIdx;
  15855. var elementInjector = null;
  15856. if (lang_1.isPresent(binder.nestedProtoView) && binder.nestedProtoView.isMergable) {
  15857. containerElementIndicesByViewIndex[nestedViewOffset] = boundElementIndex;
  15858. nestedViewOffset += binder.nestedProtoView.mergeInfo.viewCount;
  15859. }
  15860. // elementInjectors and rootElementInjectors
  15861. var protoElementInjector = binder.protoElementInjector;
  15862. if (lang_1.isPresent(protoElementInjector)) {
  15863. if (lang_1.isPresent(protoElementInjector.parent)) {
  15864. var parentElementInjector = elementInjectors[elementOffset + protoElementInjector.parent.index];
  15865. elementInjector = protoElementInjector.instantiate(parentElementInjector);
  15866. }
  15867. else {
  15868. elementInjector = protoElementInjector.instantiate(null);
  15869. rootElementInjectors.push(elementInjector);
  15870. }
  15871. }
  15872. elementInjectors[boundElementIndex] = elementInjector;
  15873. // elementRefs
  15874. var el = new element_ref_1.ElementRef_(currentView.ref, boundElementIndex, renderer);
  15875. elementRefs[el.boundElementIndex] = el;
  15876. // preBuiltObjects
  15877. if (lang_1.isPresent(elementInjector)) {
  15878. var templateRef = lang_1.isPresent(binder.nestedProtoView) &&
  15879. binder.nestedProtoView.type === viewModule.ViewType.EMBEDDED ?
  15880. new template_ref_1.TemplateRef_(el) :
  15881. null;
  15882. preBuiltObjects[boundElementIndex] =
  15883. new eli.PreBuiltObjects(viewManager, currentView, el, templateRef);
  15884. }
  15885. }
  15886. currentView.init(protoView.changeDetectorFactory(currentView), elementInjectors, rootElementInjectors, preBuiltObjects, views, elementRefs, viewContainers);
  15887. if (lang_1.isPresent(parentView) && protoView.type === viewModule.ViewType.COMPONENT) {
  15888. parentView.changeDetector.addViewChild(currentView.changeDetector);
  15889. }
  15890. elementOffset += protoView.elementBinders.length;
  15891. textOffset += protoView.textBindingCount;
  15892. }
  15893. return views[0];
  15894. };
  15895. AppViewManagerUtils.prototype.hydrateRootHostView = function (hostView, injector) {
  15896. this._hydrateView(hostView, injector, null, new Object(), null);
  15897. };
  15898. // Misnomer: this method is attaching next to the view container.
  15899. AppViewManagerUtils.prototype.attachViewInContainer = function (parentView, boundElementIndex, contextView, contextBoundElementIndex, index, view) {
  15900. if (lang_1.isBlank(contextView)) {
  15901. contextView = parentView;
  15902. contextBoundElementIndex = boundElementIndex;
  15903. }
  15904. parentView.changeDetector.addContentChild(view.changeDetector);
  15905. var viewContainer = parentView.viewContainers[boundElementIndex];
  15906. if (lang_1.isBlank(viewContainer)) {
  15907. viewContainer = new viewModule.AppViewContainer();
  15908. parentView.viewContainers[boundElementIndex] = viewContainer;
  15909. }
  15910. collection_1.ListWrapper.insert(viewContainer.views, index, view);
  15911. var elementInjector = contextView.elementInjectors[contextBoundElementIndex];
  15912. for (var i = view.rootElementInjectors.length - 1; i >= 0; i--) {
  15913. if (lang_1.isPresent(elementInjector.parent)) {
  15914. view.rootElementInjectors[i].link(elementInjector.parent);
  15915. }
  15916. }
  15917. elementInjector.traverseAndSetQueriesAsDirty();
  15918. };
  15919. AppViewManagerUtils.prototype.detachViewInContainer = function (parentView, boundElementIndex, index) {
  15920. var viewContainer = parentView.viewContainers[boundElementIndex];
  15921. var view = viewContainer.views[index];
  15922. parentView.elementInjectors[boundElementIndex].traverseAndSetQueriesAsDirty();
  15923. view.changeDetector.remove();
  15924. collection_1.ListWrapper.removeAt(viewContainer.views, index);
  15925. for (var i = 0; i < view.rootElementInjectors.length; ++i) {
  15926. var inj = view.rootElementInjectors[i];
  15927. inj.unlink();
  15928. }
  15929. };
  15930. AppViewManagerUtils.prototype.hydrateViewInContainer = function (parentView, boundElementIndex, contextView, contextBoundElementIndex, index, imperativelyCreatedProviders) {
  15931. if (lang_1.isBlank(contextView)) {
  15932. contextView = parentView;
  15933. contextBoundElementIndex = boundElementIndex;
  15934. }
  15935. var viewContainer = parentView.viewContainers[boundElementIndex];
  15936. var view = viewContainer.views[index];
  15937. var elementInjector = contextView.elementInjectors[contextBoundElementIndex];
  15938. var injector = lang_1.isPresent(imperativelyCreatedProviders) ?
  15939. di_1.Injector.fromResolvedProviders(imperativelyCreatedProviders) :
  15940. null;
  15941. this._hydrateView(view, injector, elementInjector.getHost(), contextView.context, contextView.locals);
  15942. };
  15943. /** @internal */
  15944. AppViewManagerUtils.prototype._hydrateView = function (initView, imperativelyCreatedInjector, hostElementInjector, context, parentLocals) {
  15945. var viewIdx = initView.viewOffset;
  15946. var endViewOffset = viewIdx + initView.proto.mergeInfo.viewCount - 1;
  15947. while (viewIdx <= endViewOffset) {
  15948. var currView = initView.views[viewIdx];
  15949. var currProtoView = currView.proto;
  15950. if (currView !== initView && currView.proto.type === viewModule.ViewType.EMBEDDED) {
  15951. // Don't hydrate components of embedded fragment views.
  15952. viewIdx += currView.proto.mergeInfo.viewCount;
  15953. }
  15954. else {
  15955. if (currView !== initView) {
  15956. // hydrate a nested component view
  15957. imperativelyCreatedInjector = null;
  15958. parentLocals = null;
  15959. hostElementInjector = currView.containerElementInjector;
  15960. context = hostElementInjector.getComponent();
  15961. }
  15962. currView.context = context;
  15963. currView.locals.parent = parentLocals;
  15964. var binders = currProtoView.elementBinders;
  15965. for (var binderIdx = 0; binderIdx < binders.length; binderIdx++) {
  15966. var boundElementIndex = binderIdx + currView.elementOffset;
  15967. var elementInjector = initView.elementInjectors[boundElementIndex];
  15968. if (lang_1.isPresent(elementInjector)) {
  15969. elementInjector.hydrate(imperativelyCreatedInjector, hostElementInjector, currView.preBuiltObjects[boundElementIndex]);
  15970. this._populateViewLocals(currView, elementInjector, boundElementIndex);
  15971. this._setUpEventEmitters(currView, elementInjector, boundElementIndex);
  15972. }
  15973. }
  15974. var pipes = lang_1.isPresent(hostElementInjector) ?
  15975. new pipes_1.Pipes(currView.proto.pipes, hostElementInjector.getInjector()) :
  15976. null;
  15977. currView.changeDetector.hydrate(currView.context, currView.locals, currView, pipes);
  15978. viewIdx++;
  15979. }
  15980. }
  15981. };
  15982. /** @internal */
  15983. AppViewManagerUtils.prototype._populateViewLocals = function (view, elementInjector, boundElementIdx) {
  15984. if (lang_1.isPresent(elementInjector.getDirectiveVariableBindings())) {
  15985. elementInjector.getDirectiveVariableBindings().forEach(function (directiveIndex, name) {
  15986. if (lang_1.isBlank(directiveIndex)) {
  15987. view.locals.set(name, view.elementRefs[boundElementIdx].nativeElement);
  15988. }
  15989. else {
  15990. view.locals.set(name, elementInjector.getDirectiveAtIndex(directiveIndex));
  15991. }
  15992. });
  15993. }
  15994. };
  15995. /** @internal */
  15996. AppViewManagerUtils.prototype._setUpEventEmitters = function (view, elementInjector, boundElementIndex) {
  15997. var emitters = elementInjector.getEventEmitterAccessors();
  15998. for (var directiveIndex = 0; directiveIndex < emitters.length; ++directiveIndex) {
  15999. var directiveEmitters = emitters[directiveIndex];
  16000. var directive = elementInjector.getDirectiveAtIndex(directiveIndex);
  16001. for (var eventIndex = 0; eventIndex < directiveEmitters.length; ++eventIndex) {
  16002. var eventEmitterAccessor = directiveEmitters[eventIndex];
  16003. eventEmitterAccessor.subscribe(view, boundElementIndex, directive);
  16004. }
  16005. }
  16006. };
  16007. AppViewManagerUtils.prototype.dehydrateView = function (initView) {
  16008. var endViewOffset = initView.viewOffset + initView.proto.mergeInfo.viewCount - 1;
  16009. for (var viewIdx = initView.viewOffset; viewIdx <= endViewOffset; viewIdx++) {
  16010. var currView = initView.views[viewIdx];
  16011. if (currView.hydrated()) {
  16012. if (lang_1.isPresent(currView.locals)) {
  16013. currView.locals.clearValues();
  16014. }
  16015. currView.context = null;
  16016. currView.changeDetector.dehydrate();
  16017. var binders = currView.proto.elementBinders;
  16018. for (var binderIdx = 0; binderIdx < binders.length; binderIdx++) {
  16019. var eli = initView.elementInjectors[currView.elementOffset + binderIdx];
  16020. if (lang_1.isPresent(eli)) {
  16021. eli.dehydrate();
  16022. }
  16023. }
  16024. }
  16025. }
  16026. };
  16027. AppViewManagerUtils = __decorate([
  16028. di_1.Injectable(),
  16029. __metadata('design:paramtypes', [])
  16030. ], AppViewManagerUtils);
  16031. return AppViewManagerUtils;
  16032. })();
  16033. exports.AppViewManagerUtils = AppViewManagerUtils;
  16034. /***/ },
  16035. /* 83 */
  16036. /***/ function(module, exports, __webpack_require__) {
  16037. var __extends = (this && this.__extends) || function (d, b) {
  16038. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  16039. function __() { this.constructor = d; }
  16040. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16041. };
  16042. var exceptions_1 = __webpack_require__(14);
  16043. /**
  16044. * Represents a location in a View that has an injection, change-detection and render context
  16045. * associated with it.
  16046. *
  16047. * An `ElementRef` is created for each element in the Template that contains a Directive, Component
  16048. * or data-binding.
  16049. *
  16050. * An `ElementRef` is backed by a render-specific element. In the browser, this is usually a DOM
  16051. * element.
  16052. */
  16053. var ElementRef = (function () {
  16054. function ElementRef() {
  16055. }
  16056. Object.defineProperty(ElementRef.prototype, "nativeElement", {
  16057. /**
  16058. * The underlying native element or `null` if direct access to native elements is not supported
  16059. * (e.g. when the application runs in a web worker).
  16060. *
  16061. * <div class="callout is-critical">
  16062. * <header>Use with caution</header>
  16063. * <p>
  16064. * Use this API as the last resort when direct access to DOM is needed. Use templating and
  16065. * data-binding provided by Angular instead. Alternatively you take a look at {@link Renderer}
  16066. * which provides API that can safely be used even when direct access to native elements is not
  16067. * supported.
  16068. * </p>
  16069. * <p>
  16070. * Relying on direct DOM access creates tight coupling between your application and rendering
  16071. * layers which will make it impossible to separate the two and deploy your application into a
  16072. * web worker.
  16073. * </p>
  16074. * </div>
  16075. */
  16076. get: function () { return exceptions_1.unimplemented(); },
  16077. enumerable: true,
  16078. configurable: true
  16079. });
  16080. ;
  16081. Object.defineProperty(ElementRef.prototype, "renderView", {
  16082. get: function () { return exceptions_1.unimplemented(); },
  16083. enumerable: true,
  16084. configurable: true
  16085. });
  16086. return ElementRef;
  16087. })();
  16088. exports.ElementRef = ElementRef;
  16089. var ElementRef_ = (function (_super) {
  16090. __extends(ElementRef_, _super);
  16091. function ElementRef_(parentView,
  16092. /**
  16093. * Index of the element inside the {@link ViewRef}.
  16094. *
  16095. * This is used internally by the Angular framework to locate elements.
  16096. */
  16097. boundElementIndex, _renderer) {
  16098. _super.call(this);
  16099. this.parentView = parentView;
  16100. this.boundElementIndex = boundElementIndex;
  16101. this._renderer = _renderer;
  16102. }
  16103. Object.defineProperty(ElementRef_.prototype, "renderView", {
  16104. get: function () { return this.parentView.render; },
  16105. set: function (value) { exceptions_1.unimplemented(); },
  16106. enumerable: true,
  16107. configurable: true
  16108. });
  16109. Object.defineProperty(ElementRef_.prototype, "nativeElement", {
  16110. get: function () { return this._renderer.getNativeElementSync(this); },
  16111. enumerable: true,
  16112. configurable: true
  16113. });
  16114. return ElementRef_;
  16115. })(ElementRef);
  16116. exports.ElementRef_ = ElementRef_;
  16117. /***/ },
  16118. /* 84 */
  16119. /***/ function(module, exports, __webpack_require__) {
  16120. var __extends = (this && this.__extends) || function (d, b) {
  16121. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  16122. function __() { this.constructor = d; }
  16123. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16124. };
  16125. var view_ref_1 = __webpack_require__(77);
  16126. /**
  16127. * Represents an Embedded Template that can be used to instantiate Embedded Views.
  16128. *
  16129. * You can access a `TemplateRef`, in two ways. Via a directive placed on a `<template>` element (or
  16130. * directive prefixed with `*`) and have the `TemplateRef` for this Embedded View injected into the
  16131. * constructor of the directive using the `TemplateRef` Token. Alternatively you can query for the
  16132. * `TemplateRef` from a Component or a Directive via {@link Query}.
  16133. *
  16134. * To instantiate Embedded Views based on a Template, use
  16135. * {@link ViewContainerRef#createEmbeddedView}, which will create the View and attach it to the
  16136. * View Container.
  16137. */
  16138. var TemplateRef = (function () {
  16139. function TemplateRef() {
  16140. }
  16141. return TemplateRef;
  16142. })();
  16143. exports.TemplateRef = TemplateRef;
  16144. var TemplateRef_ = (function (_super) {
  16145. __extends(TemplateRef_, _super);
  16146. function TemplateRef_(elementRef) {
  16147. _super.call(this);
  16148. this.elementRef = elementRef;
  16149. }
  16150. TemplateRef_.prototype._getProtoView = function () {
  16151. var elementRef = this.elementRef;
  16152. var parentView = view_ref_1.internalView(elementRef.parentView);
  16153. return parentView.proto.elementBinders[elementRef.boundElementIndex - parentView.elementOffset]
  16154. .nestedProtoView;
  16155. };
  16156. Object.defineProperty(TemplateRef_.prototype, "protoViewRef", {
  16157. /**
  16158. * Reference to the ProtoView used for creating Embedded Views that are based on the compiled
  16159. * Embedded Template.
  16160. */
  16161. get: function () { return this._getProtoView().ref; },
  16162. enumerable: true,
  16163. configurable: true
  16164. });
  16165. TemplateRef_.prototype.hasLocal = function (name) {
  16166. return this._getProtoView().templateVariableBindings.has(name);
  16167. };
  16168. return TemplateRef_;
  16169. })(TemplateRef);
  16170. exports.TemplateRef_ = TemplateRef_;
  16171. /***/ },
  16172. /* 85 */
  16173. /***/ function(module, exports, __webpack_require__) {
  16174. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  16175. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  16176. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  16177. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  16178. return c > 3 && r && Object.defineProperty(target, key, r), r;
  16179. };
  16180. var __metadata = (this && this.__metadata) || function (k, v) {
  16181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  16182. };
  16183. var __param = (this && this.__param) || function (paramIndex, decorator) {
  16184. return function (target, key) { decorator(target, key, paramIndex); }
  16185. };
  16186. var di_1 = __webpack_require__(6);
  16187. var lang_1 = __webpack_require__(5);
  16188. var collection_1 = __webpack_require__(12);
  16189. exports.APP_VIEW_POOL_CAPACITY = lang_1.CONST_EXPR(new di_1.OpaqueToken('AppViewPool.viewPoolCapacity'));
  16190. var AppViewPool = (function () {
  16191. function AppViewPool(poolCapacityPerProtoView) {
  16192. /** @internal */
  16193. this._pooledViewsPerProtoView = new collection_1.Map();
  16194. this._poolCapacityPerProtoView = poolCapacityPerProtoView;
  16195. }
  16196. AppViewPool.prototype.getView = function (protoView) {
  16197. var pooledViews = this._pooledViewsPerProtoView.get(protoView);
  16198. if (lang_1.isPresent(pooledViews) && pooledViews.length > 0) {
  16199. return pooledViews.pop();
  16200. }
  16201. return null;
  16202. };
  16203. AppViewPool.prototype.returnView = function (view) {
  16204. var protoView = view.proto;
  16205. var pooledViews = this._pooledViewsPerProtoView.get(protoView);
  16206. if (lang_1.isBlank(pooledViews)) {
  16207. pooledViews = [];
  16208. this._pooledViewsPerProtoView.set(protoView, pooledViews);
  16209. }
  16210. var haveRemainingCapacity = pooledViews.length < this._poolCapacityPerProtoView;
  16211. if (haveRemainingCapacity) {
  16212. pooledViews.push(view);
  16213. }
  16214. return haveRemainingCapacity;
  16215. };
  16216. AppViewPool = __decorate([
  16217. di_1.Injectable(),
  16218. __param(0, di_1.Inject(exports.APP_VIEW_POOL_CAPACITY)),
  16219. __metadata('design:paramtypes', [Object])
  16220. ], AppViewPool);
  16221. return AppViewPool;
  16222. })();
  16223. exports.AppViewPool = AppViewPool;
  16224. /***/ },
  16225. /* 86 */
  16226. /***/ function(module, exports, __webpack_require__) {
  16227. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  16228. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  16229. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  16230. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  16231. return c > 3 && r && Object.defineProperty(target, key, r), r;
  16232. };
  16233. var __metadata = (this && this.__metadata) || function (k, v) {
  16234. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  16235. };
  16236. var di_1 = __webpack_require__(6);
  16237. /**
  16238. * Listener for view creation / destruction.
  16239. */
  16240. var AppViewListener = (function () {
  16241. function AppViewListener() {
  16242. }
  16243. AppViewListener.prototype.onViewCreated = function (view) { };
  16244. AppViewListener.prototype.onViewDestroyed = function (view) { };
  16245. AppViewListener = __decorate([
  16246. di_1.Injectable(),
  16247. __metadata('design:paramtypes', [])
  16248. ], AppViewListener);
  16249. return AppViewListener;
  16250. })();
  16251. exports.AppViewListener = AppViewListener;
  16252. /***/ },
  16253. /* 87 */
  16254. /***/ function(module, exports, __webpack_require__) {
  16255. var __extends = (this && this.__extends) || function (d, b) {
  16256. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  16257. function __() { this.constructor = d; }
  16258. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16259. };
  16260. var collection_1 = __webpack_require__(12);
  16261. var exceptions_1 = __webpack_require__(14);
  16262. var lang_1 = __webpack_require__(5);
  16263. var view_ref_1 = __webpack_require__(77);
  16264. /**
  16265. * Represents a container where one or more Views can be attached.
  16266. *
  16267. * The container can contain two kinds of Views. Host Views, created by instantiating a
  16268. * {@link Component} via {@link #createHostView}, and Embedded Views, created by instantiating an
  16269. * {@link TemplateRef Embedded Template} via {@link #createEmbeddedView}.
  16270. *
  16271. * The location of the View Container within the containing View is specified by the Anchor
  16272. * `element`. Each View Container can have only one Anchor Element and each Anchor Element can only
  16273. * have a single View Container.
  16274. *
  16275. * Root elements of Views attached to this container become siblings of the Anchor Element in
  16276. * the Rendered View.
  16277. *
  16278. * To access a `ViewContainerRef` of an Element, you can either place a {@link Directive} injected
  16279. * with `ViewContainerRef` on the Element, or you obtain it via
  16280. * {@link AppViewManager#getViewContainer}.
  16281. *
  16282. * <!-- TODO(i): we are also considering ElementRef#viewContainer api -->
  16283. */
  16284. var ViewContainerRef = (function () {
  16285. function ViewContainerRef() {
  16286. }
  16287. /**
  16288. * Destroys all Views in this container.
  16289. */
  16290. ViewContainerRef.prototype.clear = function () {
  16291. for (var i = this.length - 1; i >= 0; i--) {
  16292. this.remove(i);
  16293. }
  16294. };
  16295. Object.defineProperty(ViewContainerRef.prototype, "length", {
  16296. /**
  16297. * Returns the number of Views currently attached to this container.
  16298. */
  16299. get: function () { return exceptions_1.unimplemented(); },
  16300. enumerable: true,
  16301. configurable: true
  16302. });
  16303. ;
  16304. return ViewContainerRef;
  16305. })();
  16306. exports.ViewContainerRef = ViewContainerRef;
  16307. var ViewContainerRef_ = (function (_super) {
  16308. __extends(ViewContainerRef_, _super);
  16309. function ViewContainerRef_(viewManager, element) {
  16310. _super.call(this);
  16311. this.viewManager = viewManager;
  16312. this.element = element;
  16313. }
  16314. ViewContainerRef_.prototype._getViews = function () {
  16315. var element = this.element;
  16316. var vc = view_ref_1.internalView(element.parentView).viewContainers[element.boundElementIndex];
  16317. return lang_1.isPresent(vc) ? vc.views : [];
  16318. };
  16319. ViewContainerRef_.prototype.get = function (index) { return this._getViews()[index].ref; };
  16320. Object.defineProperty(ViewContainerRef_.prototype, "length", {
  16321. get: function () { return this._getViews().length; },
  16322. enumerable: true,
  16323. configurable: true
  16324. });
  16325. // TODO(rado): profile and decide whether bounds checks should be added
  16326. // to the methods below.
  16327. ViewContainerRef_.prototype.createEmbeddedView = function (templateRef, index) {
  16328. if (index === void 0) { index = -1; }
  16329. if (index == -1)
  16330. index = this.length;
  16331. return this.viewManager.createEmbeddedViewInContainer(this.element, index, templateRef);
  16332. };
  16333. ViewContainerRef_.prototype.createHostView = function (protoViewRef, index, dynamicallyCreatedProviders) {
  16334. if (protoViewRef === void 0) { protoViewRef = null; }
  16335. if (index === void 0) { index = -1; }
  16336. if (dynamicallyCreatedProviders === void 0) { dynamicallyCreatedProviders = null; }
  16337. if (index == -1)
  16338. index = this.length;
  16339. return this.viewManager.createHostViewInContainer(this.element, index, protoViewRef, dynamicallyCreatedProviders);
  16340. };
  16341. // TODO(i): refactor insert+remove into move
  16342. ViewContainerRef_.prototype.insert = function (viewRef, index) {
  16343. if (index === void 0) { index = -1; }
  16344. if (index == -1)
  16345. index = this.length;
  16346. return this.viewManager.attachViewInContainer(this.element, index, viewRef);
  16347. };
  16348. ViewContainerRef_.prototype.indexOf = function (viewRef) {
  16349. return collection_1.ListWrapper.indexOf(this._getViews(), view_ref_1.internalView(viewRef));
  16350. };
  16351. // TODO(i): rename to destroy
  16352. ViewContainerRef_.prototype.remove = function (index) {
  16353. if (index === void 0) { index = -1; }
  16354. if (index == -1)
  16355. index = this.length - 1;
  16356. this.viewManager.destroyViewInContainer(this.element, index);
  16357. // view is intentionally not returned to the client.
  16358. };
  16359. // TODO(i): refactor insert+remove into move
  16360. ViewContainerRef_.prototype.detach = function (index) {
  16361. if (index === void 0) { index = -1; }
  16362. if (index == -1)
  16363. index = this.length - 1;
  16364. return this.viewManager.detachViewInContainer(this.element, index);
  16365. };
  16366. return ViewContainerRef_;
  16367. })(ViewContainerRef);
  16368. exports.ViewContainerRef_ = ViewContainerRef_;
  16369. /***/ },
  16370. /* 88 */
  16371. /***/ function(module, exports, __webpack_require__) {
  16372. var lang_1 = __webpack_require__(5);
  16373. var interfaces_1 = __webpack_require__(89);
  16374. function hasLifecycleHook(lcInterface, token) {
  16375. if (!(token instanceof lang_1.Type))
  16376. return false;
  16377. var proto = token.prototype;
  16378. switch (lcInterface) {
  16379. case interfaces_1.LifecycleHooks.AfterContentInit:
  16380. return !!proto.ngAfterContentInit;
  16381. case interfaces_1.LifecycleHooks.AfterContentChecked:
  16382. return !!proto.ngAfterContentChecked;
  16383. case interfaces_1.LifecycleHooks.AfterViewInit:
  16384. return !!proto.ngAfterViewInit;
  16385. case interfaces_1.LifecycleHooks.AfterViewChecked:
  16386. return !!proto.ngAfterViewChecked;
  16387. case interfaces_1.LifecycleHooks.OnChanges:
  16388. return !!proto.ngOnChanges;
  16389. case interfaces_1.LifecycleHooks.DoCheck:
  16390. return !!proto.ngDoCheck;
  16391. case interfaces_1.LifecycleHooks.OnDestroy:
  16392. return !!proto.ngOnDestroy;
  16393. case interfaces_1.LifecycleHooks.OnInit:
  16394. return !!proto.ngOnInit;
  16395. default:
  16396. return false;
  16397. }
  16398. }
  16399. exports.hasLifecycleHook = hasLifecycleHook;
  16400. /***/ },
  16401. /* 89 */
  16402. /***/ function(module, exports) {
  16403. (function (LifecycleHooks) {
  16404. LifecycleHooks[LifecycleHooks["OnInit"] = 0] = "OnInit";
  16405. LifecycleHooks[LifecycleHooks["OnDestroy"] = 1] = "OnDestroy";
  16406. LifecycleHooks[LifecycleHooks["DoCheck"] = 2] = "DoCheck";
  16407. LifecycleHooks[LifecycleHooks["OnChanges"] = 3] = "OnChanges";
  16408. LifecycleHooks[LifecycleHooks["AfterContentInit"] = 4] = "AfterContentInit";
  16409. LifecycleHooks[LifecycleHooks["AfterContentChecked"] = 5] = "AfterContentChecked";
  16410. LifecycleHooks[LifecycleHooks["AfterViewInit"] = 6] = "AfterViewInit";
  16411. LifecycleHooks[LifecycleHooks["AfterViewChecked"] = 7] = "AfterViewChecked";
  16412. })(exports.LifecycleHooks || (exports.LifecycleHooks = {}));
  16413. var LifecycleHooks = exports.LifecycleHooks;
  16414. /**
  16415. * @internal
  16416. */
  16417. exports.LIFECYCLE_HOOKS_VALUES = [
  16418. LifecycleHooks.OnInit,
  16419. LifecycleHooks.OnDestroy,
  16420. LifecycleHooks.DoCheck,
  16421. LifecycleHooks.OnChanges,
  16422. LifecycleHooks.AfterContentInit,
  16423. LifecycleHooks.AfterContentChecked,
  16424. LifecycleHooks.AfterViewInit,
  16425. LifecycleHooks.AfterViewChecked
  16426. ];
  16427. /***/ },
  16428. /* 90 */
  16429. /***/ function(module, exports, __webpack_require__) {
  16430. var collection_1 = __webpack_require__(12);
  16431. var lang_1 = __webpack_require__(5);
  16432. var async_1 = __webpack_require__(60);
  16433. /**
  16434. * An unmodifiable list of items that Angular keeps up to date when the state
  16435. * of the application changes.
  16436. *
  16437. * The type of object that {@link QueryMetadata} and {@link ViewQueryMetadata} provide.
  16438. *
  16439. * Implements an iterable interface, therefore it can be used in both ES6
  16440. * javascript `for (var i of items)` loops as well as in Angular templates with
  16441. * `*ngFor="#i of myList"`.
  16442. *
  16443. * Changes can be observed by subscribing to the changes `Observable`.
  16444. *
  16445. * NOTE: In the future this class will implement an `Observable` interface.
  16446. *
  16447. * ### Example ([live demo](http://plnkr.co/edit/RX8sJnQYl9FWuSCWme5z?p=preview))
  16448. * ```typescript
  16449. * @Component({...})
  16450. * class Container {
  16451. * constructor(@Query(Item) items: QueryList<Item>) {
  16452. * items.changes.subscribe(_ => console.log(items.length));
  16453. * }
  16454. * }
  16455. * ```
  16456. */
  16457. var QueryList = (function () {
  16458. function QueryList() {
  16459. this._results = [];
  16460. this._emitter = new async_1.EventEmitter();
  16461. }
  16462. Object.defineProperty(QueryList.prototype, "changes", {
  16463. get: function () { return this._emitter; },
  16464. enumerable: true,
  16465. configurable: true
  16466. });
  16467. Object.defineProperty(QueryList.prototype, "length", {
  16468. get: function () { return this._results.length; },
  16469. enumerable: true,
  16470. configurable: true
  16471. });
  16472. Object.defineProperty(QueryList.prototype, "first", {
  16473. get: function () { return collection_1.ListWrapper.first(this._results); },
  16474. enumerable: true,
  16475. configurable: true
  16476. });
  16477. Object.defineProperty(QueryList.prototype, "last", {
  16478. get: function () { return collection_1.ListWrapper.last(this._results); },
  16479. enumerable: true,
  16480. configurable: true
  16481. });
  16482. /**
  16483. * returns a new array with the passed in function applied to each element.
  16484. */
  16485. QueryList.prototype.map = function (fn) { return this._results.map(fn); };
  16486. /**
  16487. * returns a filtered array.
  16488. */
  16489. QueryList.prototype.filter = function (fn) { return this._results.filter(fn); };
  16490. /**
  16491. * returns a reduced value.
  16492. */
  16493. QueryList.prototype.reduce = function (fn, init) { return this._results.reduce(fn, init); };
  16494. /**
  16495. * converts QueryList into an array
  16496. */
  16497. QueryList.prototype.toArray = function () { return collection_1.ListWrapper.clone(this._results); };
  16498. QueryList.prototype[lang_1.getSymbolIterator()] = function () { return this._results[lang_1.getSymbolIterator()](); };
  16499. QueryList.prototype.toString = function () { return this._results.toString(); };
  16500. /**
  16501. * @internal
  16502. */
  16503. QueryList.prototype.reset = function (res) { this._results = res; };
  16504. /** @internal */
  16505. QueryList.prototype.notifyOnChanges = function () { this._emitter.emit(this); };
  16506. return QueryList;
  16507. })();
  16508. exports.QueryList = QueryList;
  16509. /***/ },
  16510. /* 91 */
  16511. /***/ function(module, exports) {
  16512. exports.EVENT_TARGET_SEPARATOR = ':';
  16513. var EventConfig = (function () {
  16514. function EventConfig(fieldName, eventName, isLongForm) {
  16515. this.fieldName = fieldName;
  16516. this.eventName = eventName;
  16517. this.isLongForm = isLongForm;
  16518. }
  16519. EventConfig.parse = function (eventConfig) {
  16520. var fieldName = eventConfig, eventName = eventConfig, isLongForm = false;
  16521. var separatorIdx = eventConfig.indexOf(exports.EVENT_TARGET_SEPARATOR);
  16522. if (separatorIdx > -1) {
  16523. // long format: 'fieldName: eventName'
  16524. fieldName = eventConfig.substring(0, separatorIdx).trim();
  16525. eventName = eventConfig.substring(separatorIdx + 1).trim();
  16526. isLongForm = true;
  16527. }
  16528. return new EventConfig(fieldName, eventName, isLongForm);
  16529. };
  16530. EventConfig.prototype.getFullName = function () {
  16531. return this.isLongForm ? "" + this.fieldName + exports.EVENT_TARGET_SEPARATOR + this.eventName :
  16532. this.eventName;
  16533. };
  16534. return EventConfig;
  16535. })();
  16536. exports.EventConfig = EventConfig;
  16537. /***/ },
  16538. /* 92 */
  16539. /***/ function(module, exports, __webpack_require__) {
  16540. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  16541. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  16542. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  16543. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  16544. return c > 3 && r && Object.defineProperty(target, key, r), r;
  16545. };
  16546. var __metadata = (this && this.__metadata) || function (k, v) {
  16547. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  16548. };
  16549. var di_1 = __webpack_require__(6);
  16550. var lang_1 = __webpack_require__(5);
  16551. var exceptions_1 = __webpack_require__(14);
  16552. var collection_1 = __webpack_require__(12);
  16553. var metadata_1 = __webpack_require__(3);
  16554. var reflection_1 = __webpack_require__(16);
  16555. function _isDirectiveMetadata(type) {
  16556. return type instanceof metadata_1.DirectiveMetadata;
  16557. }
  16558. /*
  16559. * Resolve a `Type` for {@link DirectiveMetadata}.
  16560. *
  16561. * This interface can be overridden by the application developer to create custom behavior.
  16562. *
  16563. * See {@link Compiler}
  16564. */
  16565. var DirectiveResolver = (function () {
  16566. function DirectiveResolver() {
  16567. }
  16568. /**
  16569. * Return {@link DirectiveMetadata} for a given `Type`.
  16570. */
  16571. DirectiveResolver.prototype.resolve = function (type) {
  16572. var typeMetadata = reflection_1.reflector.annotations(di_1.resolveForwardRef(type));
  16573. if (lang_1.isPresent(typeMetadata)) {
  16574. var metadata = typeMetadata.find(_isDirectiveMetadata);
  16575. if (lang_1.isPresent(metadata)) {
  16576. var propertyMetadata = reflection_1.reflector.propMetadata(type);
  16577. return this._mergeWithPropertyMetadata(metadata, propertyMetadata);
  16578. }
  16579. }
  16580. throw new exceptions_1.BaseException("No Directive annotation found on " + lang_1.stringify(type));
  16581. };
  16582. DirectiveResolver.prototype._mergeWithPropertyMetadata = function (dm, propertyMetadata) {
  16583. var inputs = [];
  16584. var outputs = [];
  16585. var host = {};
  16586. var queries = {};
  16587. collection_1.StringMapWrapper.forEach(propertyMetadata, function (metadata, propName) {
  16588. metadata.forEach(function (a) {
  16589. if (a instanceof metadata_1.InputMetadata) {
  16590. if (lang_1.isPresent(a.bindingPropertyName)) {
  16591. inputs.push(propName + ": " + a.bindingPropertyName);
  16592. }
  16593. else {
  16594. inputs.push(propName);
  16595. }
  16596. }
  16597. if (a instanceof metadata_1.OutputMetadata) {
  16598. if (lang_1.isPresent(a.bindingPropertyName)) {
  16599. outputs.push(propName + ": " + a.bindingPropertyName);
  16600. }
  16601. else {
  16602. outputs.push(propName);
  16603. }
  16604. }
  16605. if (a instanceof metadata_1.HostBindingMetadata) {
  16606. if (lang_1.isPresent(a.hostPropertyName)) {
  16607. host[("[" + a.hostPropertyName + "]")] = propName;
  16608. }
  16609. else {
  16610. host[("[" + propName + "]")] = propName;
  16611. }
  16612. }
  16613. if (a instanceof metadata_1.HostListenerMetadata) {
  16614. var args = lang_1.isPresent(a.args) ? a.args.join(', ') : '';
  16615. host[("(" + a.eventName + ")")] = propName + "(" + args + ")";
  16616. }
  16617. if (a instanceof metadata_1.ContentChildrenMetadata) {
  16618. queries[propName] = a;
  16619. }
  16620. if (a instanceof metadata_1.ViewChildrenMetadata) {
  16621. queries[propName] = a;
  16622. }
  16623. if (a instanceof metadata_1.ContentChildMetadata) {
  16624. queries[propName] = a;
  16625. }
  16626. if (a instanceof metadata_1.ViewChildMetadata) {
  16627. queries[propName] = a;
  16628. }
  16629. });
  16630. });
  16631. return this._merge(dm, inputs, outputs, host, queries);
  16632. };
  16633. DirectiveResolver.prototype._merge = function (dm, inputs, outputs, host, queries) {
  16634. var mergedInputs = lang_1.isPresent(dm.inputs) ? collection_1.ListWrapper.concat(dm.inputs, inputs) : inputs;
  16635. var mergedOutputs = lang_1.isPresent(dm.outputs) ? collection_1.ListWrapper.concat(dm.outputs, outputs) : outputs;
  16636. var mergedHost = lang_1.isPresent(dm.host) ? collection_1.StringMapWrapper.merge(dm.host, host) : host;
  16637. var mergedQueries = lang_1.isPresent(dm.queries) ? collection_1.StringMapWrapper.merge(dm.queries, queries) : queries;
  16638. if (dm instanceof metadata_1.ComponentMetadata) {
  16639. return new metadata_1.ComponentMetadata({
  16640. selector: dm.selector,
  16641. inputs: mergedInputs,
  16642. outputs: mergedOutputs,
  16643. host: mergedHost,
  16644. exportAs: dm.exportAs,
  16645. moduleId: dm.moduleId,
  16646. queries: mergedQueries,
  16647. changeDetection: dm.changeDetection,
  16648. providers: dm.providers,
  16649. viewProviders: dm.viewProviders
  16650. });
  16651. }
  16652. else {
  16653. return new metadata_1.DirectiveMetadata({
  16654. selector: dm.selector,
  16655. inputs: mergedInputs,
  16656. outputs: mergedOutputs,
  16657. host: mergedHost,
  16658. exportAs: dm.exportAs,
  16659. queries: mergedQueries,
  16660. providers: dm.providers
  16661. });
  16662. }
  16663. };
  16664. DirectiveResolver = __decorate([
  16665. di_1.Injectable(),
  16666. __metadata('design:paramtypes', [])
  16667. ], DirectiveResolver);
  16668. return DirectiveResolver;
  16669. })();
  16670. exports.DirectiveResolver = DirectiveResolver;
  16671. /***/ },
  16672. /* 93 */
  16673. /***/ function(module, exports, __webpack_require__) {
  16674. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  16675. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  16676. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  16677. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  16678. return c > 3 && r && Object.defineProperty(target, key, r), r;
  16679. };
  16680. var __metadata = (this && this.__metadata) || function (k, v) {
  16681. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  16682. };
  16683. var di_1 = __webpack_require__(6);
  16684. var view_1 = __webpack_require__(56);
  16685. var directives_1 = __webpack_require__(23);
  16686. var lang_1 = __webpack_require__(5);
  16687. var exceptions_1 = __webpack_require__(14);
  16688. var collection_1 = __webpack_require__(12);
  16689. var reflection_1 = __webpack_require__(16);
  16690. /**
  16691. * Resolves types to {@link ViewMetadata}.
  16692. */
  16693. var ViewResolver = (function () {
  16694. function ViewResolver() {
  16695. /** @internal */
  16696. this._cache = new collection_1.Map();
  16697. }
  16698. ViewResolver.prototype.resolve = function (component) {
  16699. var view = this._cache.get(component);
  16700. if (lang_1.isBlank(view)) {
  16701. view = this._resolve(component);
  16702. this._cache.set(component, view);
  16703. }
  16704. return view;
  16705. };
  16706. /** @internal */
  16707. ViewResolver.prototype._resolve = function (component) {
  16708. var compMeta;
  16709. var viewMeta;
  16710. reflection_1.reflector.annotations(component).forEach(function (m) {
  16711. if (m instanceof view_1.ViewMetadata) {
  16712. viewMeta = m;
  16713. }
  16714. if (m instanceof directives_1.ComponentMetadata) {
  16715. compMeta = m;
  16716. }
  16717. });
  16718. if (lang_1.isPresent(compMeta)) {
  16719. if (lang_1.isBlank(compMeta.template) && lang_1.isBlank(compMeta.templateUrl) && lang_1.isBlank(viewMeta)) {
  16720. throw new exceptions_1.BaseException("Component '" + lang_1.stringify(component) + "' must have either 'template', 'templateUrl', or '@View' set.");
  16721. }
  16722. else if (lang_1.isPresent(compMeta.template) && lang_1.isPresent(viewMeta)) {
  16723. this._throwMixingViewAndComponent("template", component);
  16724. }
  16725. else if (lang_1.isPresent(compMeta.templateUrl) && lang_1.isPresent(viewMeta)) {
  16726. this._throwMixingViewAndComponent("templateUrl", component);
  16727. }
  16728. else if (lang_1.isPresent(compMeta.directives) && lang_1.isPresent(viewMeta)) {
  16729. this._throwMixingViewAndComponent("directives", component);
  16730. }
  16731. else if (lang_1.isPresent(compMeta.pipes) && lang_1.isPresent(viewMeta)) {
  16732. this._throwMixingViewAndComponent("pipes", component);
  16733. }
  16734. else if (lang_1.isPresent(compMeta.encapsulation) && lang_1.isPresent(viewMeta)) {
  16735. this._throwMixingViewAndComponent("encapsulation", component);
  16736. }
  16737. else if (lang_1.isPresent(compMeta.styles) && lang_1.isPresent(viewMeta)) {
  16738. this._throwMixingViewAndComponent("styles", component);
  16739. }
  16740. else if (lang_1.isPresent(compMeta.styleUrls) && lang_1.isPresent(viewMeta)) {
  16741. this._throwMixingViewAndComponent("styleUrls", component);
  16742. }
  16743. else if (lang_1.isPresent(viewMeta)) {
  16744. return viewMeta;
  16745. }
  16746. else {
  16747. return new view_1.ViewMetadata({
  16748. templateUrl: compMeta.templateUrl,
  16749. template: compMeta.template,
  16750. directives: compMeta.directives,
  16751. pipes: compMeta.pipes,
  16752. encapsulation: compMeta.encapsulation,
  16753. styles: compMeta.styles,
  16754. styleUrls: compMeta.styleUrls
  16755. });
  16756. }
  16757. }
  16758. else {
  16759. if (lang_1.isBlank(viewMeta)) {
  16760. throw new exceptions_1.BaseException("No View decorator found on component '" + lang_1.stringify(component) + "'");
  16761. }
  16762. else {
  16763. return viewMeta;
  16764. }
  16765. }
  16766. return null;
  16767. };
  16768. /** @internal */
  16769. ViewResolver.prototype._throwMixingViewAndComponent = function (propertyName, component) {
  16770. throw new exceptions_1.BaseException("Component '" + lang_1.stringify(component) + "' cannot have both '" + propertyName + "' and '@View' set at the same time\"");
  16771. };
  16772. ViewResolver = __decorate([
  16773. di_1.Injectable(),
  16774. __metadata('design:paramtypes', [])
  16775. ], ViewResolver);
  16776. return ViewResolver;
  16777. })();
  16778. exports.ViewResolver = ViewResolver;
  16779. /***/ },
  16780. /* 94 */
  16781. /***/ function(module, exports, __webpack_require__) {
  16782. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  16783. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  16784. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  16785. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  16786. return c > 3 && r && Object.defineProperty(target, key, r), r;
  16787. };
  16788. var __metadata = (this && this.__metadata) || function (k, v) {
  16789. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  16790. };
  16791. var di_1 = __webpack_require__(6);
  16792. var lang_1 = __webpack_require__(5);
  16793. var exceptions_1 = __webpack_require__(14);
  16794. var metadata_1 = __webpack_require__(3);
  16795. var reflection_1 = __webpack_require__(16);
  16796. function _isPipeMetadata(type) {
  16797. return type instanceof metadata_1.PipeMetadata;
  16798. }
  16799. /**
  16800. * Resolve a `Type` for {@link PipeMetadata}.
  16801. *
  16802. * This interface can be overridden by the application developer to create custom behavior.
  16803. *
  16804. * See {@link Compiler}
  16805. */
  16806. var PipeResolver = (function () {
  16807. function PipeResolver() {
  16808. }
  16809. /**
  16810. * Return {@link PipeMetadata} for a given `Type`.
  16811. */
  16812. PipeResolver.prototype.resolve = function (type) {
  16813. var metas = reflection_1.reflector.annotations(di_1.resolveForwardRef(type));
  16814. if (lang_1.isPresent(metas)) {
  16815. var annotation = metas.find(_isPipeMetadata);
  16816. if (lang_1.isPresent(annotation)) {
  16817. return annotation;
  16818. }
  16819. }
  16820. throw new exceptions_1.BaseException("No Pipe decorator found on " + lang_1.stringify(type));
  16821. };
  16822. PipeResolver = __decorate([
  16823. di_1.Injectable(),
  16824. __metadata('design:paramtypes', [])
  16825. ], PipeResolver);
  16826. return PipeResolver;
  16827. })();
  16828. exports.PipeResolver = PipeResolver;
  16829. /***/ },
  16830. /* 95 */
  16831. /***/ function(module, exports, __webpack_require__) {
  16832. var di_1 = __webpack_require__(6);
  16833. var lang_1 = __webpack_require__(5);
  16834. /**
  16835. * A token that can be provided when bootstraping an application to make an array of directives
  16836. * available in every component of the application.
  16837. *
  16838. * ### Example
  16839. *
  16840. * ```typescript
  16841. * import {PLATFORM_DIRECTIVES} from 'angular2/core';
  16842. * import {OtherDirective} from './myDirectives';
  16843. *
  16844. * @Component({
  16845. * selector: 'my-component',
  16846. * template: `
  16847. * <!-- can use other directive even though the component does not list it in `directives` -->
  16848. * <other-directive></other-directive>
  16849. * `
  16850. * })
  16851. * export class MyComponent {
  16852. * ...
  16853. * }
  16854. *
  16855. * bootstrap(MyComponent, [provide(PLATFORM_DIRECTIVES, {useValue: [OtherDirective], multi:true})]);
  16856. * ```
  16857. */
  16858. exports.PLATFORM_DIRECTIVES = lang_1.CONST_EXPR(new di_1.OpaqueToken("Platform Directives"));
  16859. /**
  16860. * A token that can be provided when bootstraping an application to make an array of pipes
  16861. * available in every component of the application.
  16862. *
  16863. * ### Example
  16864. *
  16865. * ```typescript
  16866. * import {PLATFORM_PIPES} from 'angular2/core';
  16867. * import {OtherPipe} from './myPipe';
  16868. *
  16869. * @Component({
  16870. * selector: 'my-component',
  16871. * template: `
  16872. * {{123 | other-pipe}}
  16873. * `
  16874. * })
  16875. * export class MyComponent {
  16876. * ...
  16877. * }
  16878. *
  16879. * bootstrap(MyComponent, [provide(PLATFORM_PIPES, {useValue: [OtherPipe], multi:true})]);
  16880. * ```
  16881. */
  16882. exports.PLATFORM_PIPES = lang_1.CONST_EXPR(new di_1.OpaqueToken("Platform Pipes"));
  16883. /***/ },
  16884. /* 96 */
  16885. /***/ function(module, exports, __webpack_require__) {
  16886. var __extends = (this && this.__extends) || function (d, b) {
  16887. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  16888. function __() { this.constructor = d; }
  16889. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16890. };
  16891. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  16892. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  16893. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  16894. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  16895. return c > 3 && r && Object.defineProperty(target, key, r), r;
  16896. };
  16897. var __metadata = (this && this.__metadata) || function (k, v) {
  16898. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  16899. };
  16900. var lang_1 = __webpack_require__(5);
  16901. var exceptions_1 = __webpack_require__(14);
  16902. var api_1 = __webpack_require__(72);
  16903. var metadata_1 = __webpack_require__(3);
  16904. // Export ViewEncapsulation so that compiled templates only need to depend
  16905. // on template_commands.
  16906. var metadata_2 = __webpack_require__(3);
  16907. exports.ViewEncapsulation = metadata_2.ViewEncapsulation;
  16908. /**
  16909. * A compiled host template.
  16910. *
  16911. * This is const as we are storing it as annotation
  16912. * for the compiled component type.
  16913. */
  16914. var CompiledHostTemplate = (function () {
  16915. function CompiledHostTemplate(template) {
  16916. this.template = template;
  16917. }
  16918. CompiledHostTemplate = __decorate([
  16919. lang_1.CONST(),
  16920. __metadata('design:paramtypes', [CompiledComponentTemplate])
  16921. ], CompiledHostTemplate);
  16922. return CompiledHostTemplate;
  16923. })();
  16924. exports.CompiledHostTemplate = CompiledHostTemplate;
  16925. /**
  16926. * A compiled template.
  16927. */
  16928. var CompiledComponentTemplate = (function () {
  16929. function CompiledComponentTemplate(id, changeDetectorFactory, commands, styles) {
  16930. this.id = id;
  16931. this.changeDetectorFactory = changeDetectorFactory;
  16932. this.commands = commands;
  16933. this.styles = styles;
  16934. }
  16935. CompiledComponentTemplate = __decorate([
  16936. lang_1.CONST(),
  16937. __metadata('design:paramtypes', [String, Function, Array, Array])
  16938. ], CompiledComponentTemplate);
  16939. return CompiledComponentTemplate;
  16940. })();
  16941. exports.CompiledComponentTemplate = CompiledComponentTemplate;
  16942. var EMPTY_ARR = lang_1.CONST_EXPR([]);
  16943. var TextCmd = (function () {
  16944. function TextCmd(value, isBound, ngContentIndex) {
  16945. this.value = value;
  16946. this.isBound = isBound;
  16947. this.ngContentIndex = ngContentIndex;
  16948. }
  16949. TextCmd.prototype.visit = function (visitor, context) {
  16950. return visitor.visitText(this, context);
  16951. };
  16952. TextCmd = __decorate([
  16953. lang_1.CONST(),
  16954. __metadata('design:paramtypes', [String, Boolean, Number])
  16955. ], TextCmd);
  16956. return TextCmd;
  16957. })();
  16958. exports.TextCmd = TextCmd;
  16959. var NgContentCmd = (function () {
  16960. function NgContentCmd(index, ngContentIndex) {
  16961. this.index = index;
  16962. this.ngContentIndex = ngContentIndex;
  16963. this.isBound = false;
  16964. }
  16965. NgContentCmd.prototype.visit = function (visitor, context) {
  16966. return visitor.visitNgContent(this, context);
  16967. };
  16968. NgContentCmd = __decorate([
  16969. lang_1.CONST(),
  16970. __metadata('design:paramtypes', [Number, Number])
  16971. ], NgContentCmd);
  16972. return NgContentCmd;
  16973. })();
  16974. exports.NgContentCmd = NgContentCmd;
  16975. var IBeginElementCmd = (function (_super) {
  16976. __extends(IBeginElementCmd, _super);
  16977. function IBeginElementCmd() {
  16978. _super.apply(this, arguments);
  16979. }
  16980. Object.defineProperty(IBeginElementCmd.prototype, "variableNameAndValues", {
  16981. get: function () { return exceptions_1.unimplemented(); },
  16982. enumerable: true,
  16983. configurable: true
  16984. });
  16985. Object.defineProperty(IBeginElementCmd.prototype, "eventTargetAndNames", {
  16986. get: function () { return exceptions_1.unimplemented(); },
  16987. enumerable: true,
  16988. configurable: true
  16989. });
  16990. Object.defineProperty(IBeginElementCmd.prototype, "directives", {
  16991. get: function () { return exceptions_1.unimplemented(); },
  16992. enumerable: true,
  16993. configurable: true
  16994. });
  16995. return IBeginElementCmd;
  16996. })(api_1.RenderBeginElementCmd);
  16997. exports.IBeginElementCmd = IBeginElementCmd;
  16998. var BeginElementCmd = (function () {
  16999. function BeginElementCmd(name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, isBound, ngContentIndex) {
  17000. this.name = name;
  17001. this.attrNameAndValues = attrNameAndValues;
  17002. this.eventTargetAndNames = eventTargetAndNames;
  17003. this.variableNameAndValues = variableNameAndValues;
  17004. this.directives = directives;
  17005. this.isBound = isBound;
  17006. this.ngContentIndex = ngContentIndex;
  17007. }
  17008. BeginElementCmd.prototype.visit = function (visitor, context) {
  17009. return visitor.visitBeginElement(this, context);
  17010. };
  17011. BeginElementCmd = __decorate([
  17012. lang_1.CONST(),
  17013. __metadata('design:paramtypes', [String, Array, Array, Array, Array, Boolean, Number])
  17014. ], BeginElementCmd);
  17015. return BeginElementCmd;
  17016. })();
  17017. exports.BeginElementCmd = BeginElementCmd;
  17018. var EndElementCmd = (function () {
  17019. function EndElementCmd() {
  17020. }
  17021. EndElementCmd.prototype.visit = function (visitor, context) {
  17022. return visitor.visitEndElement(context);
  17023. };
  17024. EndElementCmd = __decorate([
  17025. lang_1.CONST(),
  17026. __metadata('design:paramtypes', [])
  17027. ], EndElementCmd);
  17028. return EndElementCmd;
  17029. })();
  17030. exports.EndElementCmd = EndElementCmd;
  17031. var BeginComponentCmd = (function () {
  17032. function BeginComponentCmd(name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, encapsulation, ngContentIndex,
  17033. // Note: the template needs to be stored as a function
  17034. // so that we can resolve cycles
  17035. templateGetter /*() => CompiledComponentTemplate*/) {
  17036. this.name = name;
  17037. this.attrNameAndValues = attrNameAndValues;
  17038. this.eventTargetAndNames = eventTargetAndNames;
  17039. this.variableNameAndValues = variableNameAndValues;
  17040. this.directives = directives;
  17041. this.encapsulation = encapsulation;
  17042. this.ngContentIndex = ngContentIndex;
  17043. this.templateGetter = templateGetter;
  17044. this.isBound = true;
  17045. }
  17046. Object.defineProperty(BeginComponentCmd.prototype, "templateId", {
  17047. get: function () { return this.templateGetter().id; },
  17048. enumerable: true,
  17049. configurable: true
  17050. });
  17051. BeginComponentCmd.prototype.visit = function (visitor, context) {
  17052. return visitor.visitBeginComponent(this, context);
  17053. };
  17054. BeginComponentCmd = __decorate([
  17055. lang_1.CONST(),
  17056. __metadata('design:paramtypes', [String, Array, Array, Array, Array, Number, Number, Function])
  17057. ], BeginComponentCmd);
  17058. return BeginComponentCmd;
  17059. })();
  17060. exports.BeginComponentCmd = BeginComponentCmd;
  17061. var EndComponentCmd = (function () {
  17062. function EndComponentCmd() {
  17063. }
  17064. EndComponentCmd.prototype.visit = function (visitor, context) {
  17065. return visitor.visitEndComponent(context);
  17066. };
  17067. EndComponentCmd = __decorate([
  17068. lang_1.CONST(),
  17069. __metadata('design:paramtypes', [])
  17070. ], EndComponentCmd);
  17071. return EndComponentCmd;
  17072. })();
  17073. exports.EndComponentCmd = EndComponentCmd;
  17074. var EmbeddedTemplateCmd = (function () {
  17075. function EmbeddedTemplateCmd(attrNameAndValues, variableNameAndValues, directives, isMerged, ngContentIndex, changeDetectorFactory, children) {
  17076. this.attrNameAndValues = attrNameAndValues;
  17077. this.variableNameAndValues = variableNameAndValues;
  17078. this.directives = directives;
  17079. this.isMerged = isMerged;
  17080. this.ngContentIndex = ngContentIndex;
  17081. this.changeDetectorFactory = changeDetectorFactory;
  17082. this.children = children;
  17083. this.isBound = true;
  17084. this.name = null;
  17085. this.eventTargetAndNames = EMPTY_ARR;
  17086. }
  17087. EmbeddedTemplateCmd.prototype.visit = function (visitor, context) {
  17088. return visitor.visitEmbeddedTemplate(this, context);
  17089. };
  17090. EmbeddedTemplateCmd = __decorate([
  17091. lang_1.CONST(),
  17092. __metadata('design:paramtypes', [Array, Array, Array, Boolean, Number, Function, Array])
  17093. ], EmbeddedTemplateCmd);
  17094. return EmbeddedTemplateCmd;
  17095. })();
  17096. exports.EmbeddedTemplateCmd = EmbeddedTemplateCmd;
  17097. function visitAllCommands(visitor, cmds, context) {
  17098. if (context === void 0) { context = null; }
  17099. for (var i = 0; i < cmds.length; i++) {
  17100. cmds[i].visit(visitor, context);
  17101. }
  17102. }
  17103. exports.visitAllCommands = visitAllCommands;
  17104. /***/ },
  17105. /* 97 */
  17106. /***/ function(module, exports, __webpack_require__) {
  17107. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  17108. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  17109. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  17110. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  17111. return c > 3 && r && Object.defineProperty(target, key, r), r;
  17112. };
  17113. var __metadata = (this && this.__metadata) || function (k, v) {
  17114. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  17115. };
  17116. var di_1 = __webpack_require__(6);
  17117. var lang_1 = __webpack_require__(5);
  17118. var Console = (function () {
  17119. function Console() {
  17120. }
  17121. Console.prototype.log = function (message) { lang_1.print(message); };
  17122. Console = __decorate([
  17123. di_1.Injectable(),
  17124. __metadata('design:paramtypes', [])
  17125. ], Console);
  17126. return Console;
  17127. })();
  17128. exports.Console = Console;
  17129. /***/ },
  17130. /* 98 */
  17131. /***/ function(module, exports, __webpack_require__) {
  17132. // Public API for Zone
  17133. var ng_zone_1 = __webpack_require__(66);
  17134. exports.NgZone = ng_zone_1.NgZone;
  17135. exports.NgZoneError = ng_zone_1.NgZoneError;
  17136. /***/ },
  17137. /* 99 */
  17138. /***/ function(module, exports, __webpack_require__) {
  17139. // Public API for render
  17140. var api_1 = __webpack_require__(72);
  17141. exports.Renderer = api_1.Renderer;
  17142. exports.RenderViewRef = api_1.RenderViewRef;
  17143. exports.RenderProtoViewRef = api_1.RenderProtoViewRef;
  17144. exports.RenderFragmentRef = api_1.RenderFragmentRef;
  17145. exports.RenderViewWithFragments = api_1.RenderViewWithFragments;
  17146. exports.RenderTemplateCmd = api_1.RenderTemplateCmd;
  17147. exports.RenderTextCmd = api_1.RenderTextCmd;
  17148. exports.RenderNgContentCmd = api_1.RenderNgContentCmd;
  17149. exports.RenderBeginElementCmd = api_1.RenderBeginElementCmd;
  17150. exports.RenderBeginComponentCmd = api_1.RenderBeginComponentCmd;
  17151. exports.RenderEmbeddedTemplateCmd = api_1.RenderEmbeddedTemplateCmd;
  17152. exports.RenderBeginCmd = api_1.RenderBeginCmd;
  17153. exports.RenderComponentTemplate = api_1.RenderComponentTemplate;
  17154. /***/ },
  17155. /* 100 */
  17156. /***/ function(module, exports, __webpack_require__) {
  17157. // Public API for compiler
  17158. var directive_resolver_1 = __webpack_require__(92);
  17159. exports.DirectiveResolver = directive_resolver_1.DirectiveResolver;
  17160. var view_resolver_1 = __webpack_require__(93);
  17161. exports.ViewResolver = view_resolver_1.ViewResolver;
  17162. var compiler_1 = __webpack_require__(70);
  17163. exports.Compiler = compiler_1.Compiler;
  17164. var view_manager_1 = __webpack_require__(81);
  17165. exports.AppViewManager = view_manager_1.AppViewManager;
  17166. var query_list_1 = __webpack_require__(90);
  17167. exports.QueryList = query_list_1.QueryList;
  17168. var dynamic_component_loader_1 = __webpack_require__(69);
  17169. exports.DynamicComponentLoader = dynamic_component_loader_1.DynamicComponentLoader;
  17170. var element_ref_1 = __webpack_require__(83);
  17171. exports.ElementRef = element_ref_1.ElementRef;
  17172. var template_ref_1 = __webpack_require__(84);
  17173. exports.TemplateRef = template_ref_1.TemplateRef;
  17174. var view_ref_1 = __webpack_require__(77);
  17175. exports.ViewRef = view_ref_1.ViewRef;
  17176. exports.ProtoViewRef = view_ref_1.ProtoViewRef;
  17177. var view_container_ref_1 = __webpack_require__(87);
  17178. exports.ViewContainerRef = view_container_ref_1.ViewContainerRef;
  17179. var dynamic_component_loader_2 = __webpack_require__(69);
  17180. exports.ComponentRef = dynamic_component_loader_2.ComponentRef;
  17181. /***/ },
  17182. /* 101 */
  17183. /***/ function(module, exports, __webpack_require__) {
  17184. var __extends = (this && this.__extends) || function (d, b) {
  17185. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  17186. function __() { this.constructor = d; }
  17187. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17188. };
  17189. var lang_1 = __webpack_require__(5);
  17190. var exceptions_1 = __webpack_require__(14);
  17191. var view_1 = __webpack_require__(76);
  17192. var view_ref_1 = __webpack_require__(77);
  17193. /**
  17194. * A DebugElement contains information from the Angular compiler about an
  17195. * element and provides access to the corresponding ElementInjector and
  17196. * underlying DOM Element, as well as a way to query for children.
  17197. *
  17198. * A DebugElement can be obtained from a {@link ComponentFixture} or from an
  17199. * {@link ElementRef} via {@link inspectElement}.
  17200. */
  17201. var DebugElement = (function () {
  17202. function DebugElement() {
  17203. }
  17204. Object.defineProperty(DebugElement.prototype, "componentInstance", {
  17205. /**
  17206. * Return the instance of the component associated with this element, if any.
  17207. */
  17208. get: function () { return exceptions_1.unimplemented(); },
  17209. enumerable: true,
  17210. configurable: true
  17211. });
  17212. ;
  17213. Object.defineProperty(DebugElement.prototype, "nativeElement", {
  17214. /**
  17215. * Return the native HTML element for this DebugElement.
  17216. */
  17217. get: function () { return exceptions_1.unimplemented(); },
  17218. enumerable: true,
  17219. configurable: true
  17220. });
  17221. ;
  17222. Object.defineProperty(DebugElement.prototype, "elementRef", {
  17223. /**
  17224. * Return an Angular {@link ElementRef} for this element.
  17225. */
  17226. get: function () { return exceptions_1.unimplemented(); },
  17227. enumerable: true,
  17228. configurable: true
  17229. });
  17230. ;
  17231. Object.defineProperty(DebugElement.prototype, "children", {
  17232. /**
  17233. * Get child DebugElements from within the Light DOM.
  17234. *
  17235. * @return {DebugElement[]}
  17236. */
  17237. get: function () { return exceptions_1.unimplemented(); },
  17238. enumerable: true,
  17239. configurable: true
  17240. });
  17241. ;
  17242. Object.defineProperty(DebugElement.prototype, "componentViewChildren", {
  17243. /**
  17244. * Get the root DebugElement children of a component. Returns an empty
  17245. * list if the current DebugElement is not a component root.
  17246. *
  17247. * @return {DebugElement[]}
  17248. */
  17249. get: function () { return exceptions_1.unimplemented(); },
  17250. enumerable: true,
  17251. configurable: true
  17252. });
  17253. ;
  17254. /**
  17255. * Return the first descendant TestElement matching the given predicate
  17256. * and scope.
  17257. *
  17258. * @param {Function: boolean} predicate
  17259. * @param {Scope} scope
  17260. *
  17261. * @return {DebugElement}
  17262. */
  17263. DebugElement.prototype.query = function (predicate, scope) {
  17264. if (scope === void 0) { scope = Scope.all; }
  17265. var results = this.queryAll(predicate, scope);
  17266. return results.length > 0 ? results[0] : null;
  17267. };
  17268. /**
  17269. * Return descendant TestElememts matching the given predicate
  17270. * and scope.
  17271. *
  17272. * @param {Function: boolean} predicate
  17273. * @param {Scope} scope
  17274. *
  17275. * @return {DebugElement[]}
  17276. */
  17277. DebugElement.prototype.queryAll = function (predicate, scope) {
  17278. if (scope === void 0) { scope = Scope.all; }
  17279. var elementsInScope = scope(this);
  17280. return elementsInScope.filter(predicate);
  17281. };
  17282. return DebugElement;
  17283. })();
  17284. exports.DebugElement = DebugElement;
  17285. var DebugElement_ = (function (_super) {
  17286. __extends(DebugElement_, _super);
  17287. function DebugElement_(_parentView, _boundElementIndex) {
  17288. _super.call(this);
  17289. this._parentView = _parentView;
  17290. this._boundElementIndex = _boundElementIndex;
  17291. this._elementInjector = this._parentView.elementInjectors[this._boundElementIndex];
  17292. }
  17293. Object.defineProperty(DebugElement_.prototype, "componentInstance", {
  17294. get: function () {
  17295. if (!lang_1.isPresent(this._elementInjector)) {
  17296. return null;
  17297. }
  17298. return this._elementInjector.getComponent();
  17299. },
  17300. enumerable: true,
  17301. configurable: true
  17302. });
  17303. Object.defineProperty(DebugElement_.prototype, "nativeElement", {
  17304. get: function () { return this.elementRef.nativeElement; },
  17305. enumerable: true,
  17306. configurable: true
  17307. });
  17308. Object.defineProperty(DebugElement_.prototype, "elementRef", {
  17309. get: function () { return this._parentView.elementRefs[this._boundElementIndex]; },
  17310. enumerable: true,
  17311. configurable: true
  17312. });
  17313. DebugElement_.prototype.getDirectiveInstance = function (directiveIndex) {
  17314. return this._elementInjector.getDirectiveAtIndex(directiveIndex);
  17315. };
  17316. Object.defineProperty(DebugElement_.prototype, "children", {
  17317. get: function () {
  17318. return this._getChildElements(this._parentView, this._boundElementIndex);
  17319. },
  17320. enumerable: true,
  17321. configurable: true
  17322. });
  17323. Object.defineProperty(DebugElement_.prototype, "componentViewChildren", {
  17324. get: function () {
  17325. var shadowView = this._parentView.getNestedView(this._boundElementIndex);
  17326. if (!lang_1.isPresent(shadowView) || shadowView.proto.type !== view_1.ViewType.COMPONENT) {
  17327. // The current element is not a component.
  17328. return [];
  17329. }
  17330. return this._getChildElements(shadowView, null);
  17331. },
  17332. enumerable: true,
  17333. configurable: true
  17334. });
  17335. DebugElement_.prototype.triggerEventHandler = function (eventName, eventObj) {
  17336. this._parentView.triggerEventHandlers(eventName, eventObj, this._boundElementIndex);
  17337. };
  17338. DebugElement_.prototype.hasDirective = function (type) {
  17339. if (!lang_1.isPresent(this._elementInjector)) {
  17340. return false;
  17341. }
  17342. return this._elementInjector.hasDirective(type);
  17343. };
  17344. DebugElement_.prototype.inject = function (type) {
  17345. if (!lang_1.isPresent(this._elementInjector)) {
  17346. return null;
  17347. }
  17348. return this._elementInjector.get(type);
  17349. };
  17350. DebugElement_.prototype.getLocal = function (name) { return this._parentView.locals.get(name); };
  17351. /** @internal */
  17352. DebugElement_.prototype._getChildElements = function (view, parentBoundElementIndex) {
  17353. var _this = this;
  17354. var els = [];
  17355. var parentElementBinder = null;
  17356. if (lang_1.isPresent(parentBoundElementIndex)) {
  17357. parentElementBinder = view.proto.elementBinders[parentBoundElementIndex - view.elementOffset];
  17358. }
  17359. for (var i = 0; i < view.proto.elementBinders.length; ++i) {
  17360. var binder = view.proto.elementBinders[i];
  17361. if (binder.parent == parentElementBinder) {
  17362. els.push(new DebugElement_(view, view.elementOffset + i));
  17363. var views = view.viewContainers[view.elementOffset + i];
  17364. if (lang_1.isPresent(views)) {
  17365. views.views.forEach(function (nextView) { els = els.concat(_this._getChildElements(nextView, null)); });
  17366. }
  17367. }
  17368. }
  17369. return els;
  17370. };
  17371. return DebugElement_;
  17372. })(DebugElement);
  17373. exports.DebugElement_ = DebugElement_;
  17374. /**
  17375. * Returns a {@link DebugElement} for an {@link ElementRef}.
  17376. *
  17377. * @param {ElementRef}: elementRef
  17378. * @return {DebugElement}
  17379. */
  17380. function inspectElement(elementRef) {
  17381. return new DebugElement_(view_ref_1.internalView(elementRef.parentView), elementRef.boundElementIndex);
  17382. }
  17383. exports.inspectElement = inspectElement;
  17384. /**
  17385. * Maps an array of {@link DebugElement}s to an array of native DOM elements.
  17386. */
  17387. function asNativeElements(arr) {
  17388. return arr.map(function (debugEl) { return debugEl.nativeElement; });
  17389. }
  17390. exports.asNativeElements = asNativeElements;
  17391. /**
  17392. * Set of scope functions used with {@link DebugElement}'s query functionality.
  17393. */
  17394. var Scope = (function () {
  17395. function Scope() {
  17396. }
  17397. /**
  17398. * Scope queries to both the light dom and view of an element and its
  17399. * children.
  17400. *
  17401. * ## Example
  17402. *
  17403. * {@example core/debug/ts/debug_element/debug_element.ts region='scope_all'}
  17404. */
  17405. Scope.all = function (debugElement) {
  17406. var scope = [];
  17407. scope.push(debugElement);
  17408. debugElement.children.forEach(function (child) { return scope = scope.concat(Scope.all(child)); });
  17409. debugElement.componentViewChildren.forEach(function (child) { return scope = scope.concat(Scope.all(child)); });
  17410. return scope;
  17411. };
  17412. /**
  17413. * Scope queries to the light dom of an element and its children.
  17414. *
  17415. * ## Example
  17416. *
  17417. * {@example core/debug/ts/debug_element/debug_element.ts region='scope_light'}
  17418. */
  17419. Scope.light = function (debugElement) {
  17420. var scope = [];
  17421. debugElement.children.forEach(function (child) {
  17422. scope.push(child);
  17423. scope = scope.concat(Scope.light(child));
  17424. });
  17425. return scope;
  17426. };
  17427. /**
  17428. * Scope queries to the view of an element of its children.
  17429. *
  17430. * ## Example
  17431. *
  17432. * {@example core/debug/ts/debug_element/debug_element.ts region='scope_view'}
  17433. */
  17434. Scope.view = function (debugElement) {
  17435. var scope = [];
  17436. debugElement.componentViewChildren.forEach(function (child) {
  17437. scope.push(child);
  17438. scope = scope.concat(Scope.light(child));
  17439. });
  17440. return scope;
  17441. };
  17442. return Scope;
  17443. })();
  17444. exports.Scope = Scope;
  17445. /***/ },
  17446. /* 102 */
  17447. /***/ function(module, exports, __webpack_require__) {
  17448. var lang_1 = __webpack_require__(5);
  17449. var di_1 = __webpack_require__(6);
  17450. var console_1 = __webpack_require__(97);
  17451. var reflection_1 = __webpack_require__(16);
  17452. var testability_1 = __webpack_require__(68);
  17453. function _reflector() {
  17454. return reflection_1.reflector;
  17455. }
  17456. /**
  17457. * A default set of providers which should be included in any Angular platform.
  17458. */
  17459. exports.PLATFORM_COMMON_PROVIDERS = lang_1.CONST_EXPR([new di_1.Provider(reflection_1.Reflector, { useFactory: _reflector, deps: [] }), testability_1.TestabilityRegistry, console_1.Console]);
  17460. /***/ },
  17461. /* 103 */
  17462. /***/ function(module, exports, __webpack_require__) {
  17463. var lang_1 = __webpack_require__(5);
  17464. var di_1 = __webpack_require__(6);
  17465. var application_tokens_1 = __webpack_require__(67);
  17466. var change_detection_1 = __webpack_require__(25);
  17467. var view_pool_1 = __webpack_require__(85);
  17468. var view_manager_1 = __webpack_require__(81);
  17469. var view_manager_2 = __webpack_require__(81);
  17470. var view_manager_utils_1 = __webpack_require__(82);
  17471. var view_resolver_1 = __webpack_require__(93);
  17472. var view_listener_1 = __webpack_require__(86);
  17473. var proto_view_factory_1 = __webpack_require__(71);
  17474. var directive_resolver_1 = __webpack_require__(92);
  17475. var pipe_resolver_1 = __webpack_require__(94);
  17476. var compiler_1 = __webpack_require__(70);
  17477. var compiler_2 = __webpack_require__(70);
  17478. var dynamic_component_loader_1 = __webpack_require__(69);
  17479. var dynamic_component_loader_2 = __webpack_require__(69);
  17480. /**
  17481. * A default set of providers which should be included in any Angular
  17482. * application, regardless of the platform it runs onto.
  17483. */
  17484. exports.APPLICATION_COMMON_PROVIDERS = lang_1.CONST_EXPR([
  17485. new di_1.Provider(compiler_1.Compiler, { useClass: compiler_2.Compiler_ }),
  17486. application_tokens_1.APP_ID_RANDOM_PROVIDER,
  17487. view_pool_1.AppViewPool,
  17488. new di_1.Provider(view_pool_1.APP_VIEW_POOL_CAPACITY, { useValue: 10000 }),
  17489. new di_1.Provider(view_manager_1.AppViewManager, { useClass: view_manager_2.AppViewManager_ }),
  17490. view_manager_utils_1.AppViewManagerUtils,
  17491. view_listener_1.AppViewListener,
  17492. proto_view_factory_1.ProtoViewFactory,
  17493. view_resolver_1.ViewResolver,
  17494. new di_1.Provider(change_detection_1.IterableDiffers, { useValue: change_detection_1.defaultIterableDiffers }),
  17495. new di_1.Provider(change_detection_1.KeyValueDiffers, { useValue: change_detection_1.defaultKeyValueDiffers }),
  17496. directive_resolver_1.DirectiveResolver,
  17497. pipe_resolver_1.PipeResolver,
  17498. new di_1.Provider(dynamic_component_loader_1.DynamicComponentLoader, { useClass: dynamic_component_loader_2.DynamicComponentLoader_ })
  17499. ]);
  17500. /***/ },
  17501. /* 104 */
  17502. /***/ function(module, exports, __webpack_require__) {
  17503. function __export(m) {
  17504. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  17505. }
  17506. __export(__webpack_require__(105));
  17507. __export(__webpack_require__(115));
  17508. __export(__webpack_require__(123));
  17509. __export(__webpack_require__(146));
  17510. /***/ },
  17511. /* 105 */
  17512. /***/ function(module, exports, __webpack_require__) {
  17513. /**
  17514. * @module
  17515. * @description
  17516. * This module provides a set of common Pipes.
  17517. */
  17518. var async_pipe_1 = __webpack_require__(106);
  17519. var uppercase_pipe_1 = __webpack_require__(108);
  17520. var lowercase_pipe_1 = __webpack_require__(109);
  17521. var json_pipe_1 = __webpack_require__(110);
  17522. var slice_pipe_1 = __webpack_require__(111);
  17523. var date_pipe_1 = __webpack_require__(112);
  17524. var number_pipe_1 = __webpack_require__(114);
  17525. var lang_1 = __webpack_require__(5);
  17526. var async_pipe_2 = __webpack_require__(106);
  17527. exports.AsyncPipe = async_pipe_2.AsyncPipe;
  17528. var date_pipe_2 = __webpack_require__(112);
  17529. exports.DatePipe = date_pipe_2.DatePipe;
  17530. var json_pipe_2 = __webpack_require__(110);
  17531. exports.JsonPipe = json_pipe_2.JsonPipe;
  17532. var slice_pipe_2 = __webpack_require__(111);
  17533. exports.SlicePipe = slice_pipe_2.SlicePipe;
  17534. var lowercase_pipe_2 = __webpack_require__(109);
  17535. exports.LowerCasePipe = lowercase_pipe_2.LowerCasePipe;
  17536. var number_pipe_2 = __webpack_require__(114);
  17537. exports.NumberPipe = number_pipe_2.NumberPipe;
  17538. exports.DecimalPipe = number_pipe_2.DecimalPipe;
  17539. exports.PercentPipe = number_pipe_2.PercentPipe;
  17540. exports.CurrencyPipe = number_pipe_2.CurrencyPipe;
  17541. var uppercase_pipe_2 = __webpack_require__(108);
  17542. exports.UpperCasePipe = uppercase_pipe_2.UpperCasePipe;
  17543. /**
  17544. * A collection of Angular core pipes that are likely to be used in each and every
  17545. * application.
  17546. *
  17547. * This collection can be used to quickly enumerate all the built-in pipes in the `pipes`
  17548. * property of the `@Component` or `@View` decorators.
  17549. */
  17550. exports.COMMON_PIPES = lang_1.CONST_EXPR([
  17551. async_pipe_1.AsyncPipe,
  17552. uppercase_pipe_1.UpperCasePipe,
  17553. lowercase_pipe_1.LowerCasePipe,
  17554. json_pipe_1.JsonPipe,
  17555. slice_pipe_1.SlicePipe,
  17556. number_pipe_1.DecimalPipe,
  17557. number_pipe_1.PercentPipe,
  17558. number_pipe_1.CurrencyPipe,
  17559. date_pipe_1.DatePipe
  17560. ]);
  17561. /***/ },
  17562. /* 106 */
  17563. /***/ function(module, exports, __webpack_require__) {
  17564. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  17565. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  17566. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  17567. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  17568. return c > 3 && r && Object.defineProperty(target, key, r), r;
  17569. };
  17570. var __metadata = (this && this.__metadata) || function (k, v) {
  17571. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  17572. };
  17573. var lang_1 = __webpack_require__(5);
  17574. var async_1 = __webpack_require__(60);
  17575. var core_1 = __webpack_require__(2);
  17576. var invalid_pipe_argument_exception_1 = __webpack_require__(107);
  17577. var ObservableStrategy = (function () {
  17578. function ObservableStrategy() {
  17579. }
  17580. ObservableStrategy.prototype.createSubscription = function (async, updateLatestValue) {
  17581. return async_1.ObservableWrapper.subscribe(async, updateLatestValue, function (e) { throw e; });
  17582. };
  17583. ObservableStrategy.prototype.dispose = function (subscription) { async_1.ObservableWrapper.dispose(subscription); };
  17584. ObservableStrategy.prototype.onDestroy = function (subscription) { async_1.ObservableWrapper.dispose(subscription); };
  17585. return ObservableStrategy;
  17586. })();
  17587. var PromiseStrategy = (function () {
  17588. function PromiseStrategy() {
  17589. }
  17590. PromiseStrategy.prototype.createSubscription = function (async, updateLatestValue) {
  17591. return async.then(updateLatestValue);
  17592. };
  17593. PromiseStrategy.prototype.dispose = function (subscription) { };
  17594. PromiseStrategy.prototype.onDestroy = function (subscription) { };
  17595. return PromiseStrategy;
  17596. })();
  17597. var _promiseStrategy = new PromiseStrategy();
  17598. var _observableStrategy = new ObservableStrategy();
  17599. /**
  17600. * The `async` pipe subscribes to an Observable or Promise and returns the latest value it has
  17601. * emitted.
  17602. * When a new value is emitted, the `async` pipe marks the component to be checked for changes.
  17603. *
  17604. * ### Example
  17605. *
  17606. * This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
  17607. * promise.
  17608. *
  17609. * {@example core/pipes/ts/async_pipe/async_pipe_example.ts region='AsyncPipe'}
  17610. *
  17611. * It's also possible to use `async` with Observables. The example below binds the `time` Observable
  17612. * to the view. Every 500ms, the `time` Observable updates the view with the current time.
  17613. *
  17614. * ```typescript
  17615. * ```
  17616. */
  17617. var AsyncPipe = (function () {
  17618. function AsyncPipe(_ref) {
  17619. /** @internal */
  17620. this._latestValue = null;
  17621. /** @internal */
  17622. this._latestReturnedValue = null;
  17623. /** @internal */
  17624. this._subscription = null;
  17625. /** @internal */
  17626. this._obj = null;
  17627. this._strategy = null;
  17628. this._ref = _ref;
  17629. }
  17630. AsyncPipe.prototype.ngOnDestroy = function () {
  17631. if (lang_1.isPresent(this._subscription)) {
  17632. this._dispose();
  17633. }
  17634. };
  17635. AsyncPipe.prototype.transform = function (obj, args) {
  17636. if (lang_1.isBlank(this._obj)) {
  17637. if (lang_1.isPresent(obj)) {
  17638. this._subscribe(obj);
  17639. }
  17640. return this._latestValue;
  17641. }
  17642. if (obj !== this._obj) {
  17643. this._dispose();
  17644. return this.transform(obj);
  17645. }
  17646. if (this._latestValue === this._latestReturnedValue) {
  17647. return this._latestReturnedValue;
  17648. }
  17649. else {
  17650. this._latestReturnedValue = this._latestValue;
  17651. return core_1.WrappedValue.wrap(this._latestValue);
  17652. }
  17653. };
  17654. /** @internal */
  17655. AsyncPipe.prototype._subscribe = function (obj) {
  17656. var _this = this;
  17657. this._obj = obj;
  17658. this._strategy = this._selectStrategy(obj);
  17659. this._subscription =
  17660. this._strategy.createSubscription(obj, function (value) { return _this._updateLatestValue(obj, value); });
  17661. };
  17662. /** @internal */
  17663. AsyncPipe.prototype._selectStrategy = function (obj) {
  17664. if (lang_1.isPromise(obj)) {
  17665. return _promiseStrategy;
  17666. }
  17667. else if (async_1.ObservableWrapper.isObservable(obj)) {
  17668. return _observableStrategy;
  17669. }
  17670. else {
  17671. throw new invalid_pipe_argument_exception_1.InvalidPipeArgumentException(AsyncPipe, obj);
  17672. }
  17673. };
  17674. /** @internal */
  17675. AsyncPipe.prototype._dispose = function () {
  17676. this._strategy.dispose(this._subscription);
  17677. this._latestValue = null;
  17678. this._latestReturnedValue = null;
  17679. this._subscription = null;
  17680. this._obj = null;
  17681. };
  17682. /** @internal */
  17683. AsyncPipe.prototype._updateLatestValue = function (async, value) {
  17684. if (async === this._obj) {
  17685. this._latestValue = value;
  17686. this._ref.markForCheck();
  17687. }
  17688. };
  17689. AsyncPipe = __decorate([
  17690. core_1.Pipe({ name: 'async', pure: false }),
  17691. core_1.Injectable(),
  17692. __metadata('design:paramtypes', [core_1.ChangeDetectorRef])
  17693. ], AsyncPipe);
  17694. return AsyncPipe;
  17695. })();
  17696. exports.AsyncPipe = AsyncPipe;
  17697. /***/ },
  17698. /* 107 */
  17699. /***/ function(module, exports, __webpack_require__) {
  17700. var __extends = (this && this.__extends) || function (d, b) {
  17701. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  17702. function __() { this.constructor = d; }
  17703. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17704. };
  17705. var lang_1 = __webpack_require__(5);
  17706. var exceptions_1 = __webpack_require__(14);
  17707. var InvalidPipeArgumentException = (function (_super) {
  17708. __extends(InvalidPipeArgumentException, _super);
  17709. function InvalidPipeArgumentException(type, value) {
  17710. _super.call(this, "Invalid argument '" + value + "' for pipe '" + lang_1.stringify(type) + "'");
  17711. }
  17712. return InvalidPipeArgumentException;
  17713. })(exceptions_1.BaseException);
  17714. exports.InvalidPipeArgumentException = InvalidPipeArgumentException;
  17715. /***/ },
  17716. /* 108 */
  17717. /***/ function(module, exports, __webpack_require__) {
  17718. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  17719. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  17720. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  17721. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  17722. return c > 3 && r && Object.defineProperty(target, key, r), r;
  17723. };
  17724. var __metadata = (this && this.__metadata) || function (k, v) {
  17725. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  17726. };
  17727. var lang_1 = __webpack_require__(5);
  17728. var core_1 = __webpack_require__(2);
  17729. var invalid_pipe_argument_exception_1 = __webpack_require__(107);
  17730. /**
  17731. * Implements uppercase transforms to text.
  17732. *
  17733. * ### Example
  17734. *
  17735. * {@example core/pipes/ts/lowerupper_pipe/lowerupper_pipe_example.ts region='LowerUpperPipe'}
  17736. */
  17737. var UpperCasePipe = (function () {
  17738. function UpperCasePipe() {
  17739. }
  17740. UpperCasePipe.prototype.transform = function (value, args) {
  17741. if (args === void 0) { args = null; }
  17742. if (lang_1.isBlank(value))
  17743. return value;
  17744. if (!lang_1.isString(value)) {
  17745. throw new invalid_pipe_argument_exception_1.InvalidPipeArgumentException(UpperCasePipe, value);
  17746. }
  17747. return value.toUpperCase();
  17748. };
  17749. UpperCasePipe = __decorate([
  17750. lang_1.CONST(),
  17751. core_1.Pipe({ name: 'uppercase' }),
  17752. core_1.Injectable(),
  17753. __metadata('design:paramtypes', [])
  17754. ], UpperCasePipe);
  17755. return UpperCasePipe;
  17756. })();
  17757. exports.UpperCasePipe = UpperCasePipe;
  17758. /***/ },
  17759. /* 109 */
  17760. /***/ function(module, exports, __webpack_require__) {
  17761. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  17762. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  17763. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  17764. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  17765. return c > 3 && r && Object.defineProperty(target, key, r), r;
  17766. };
  17767. var __metadata = (this && this.__metadata) || function (k, v) {
  17768. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  17769. };
  17770. var lang_1 = __webpack_require__(5);
  17771. var core_1 = __webpack_require__(2);
  17772. var invalid_pipe_argument_exception_1 = __webpack_require__(107);
  17773. /**
  17774. * Transforms text to lowercase.
  17775. *
  17776. * ### Example
  17777. *
  17778. * {@example core/pipes/ts/lowerupper_pipe/lowerupper_pipe_example.ts region='LowerUpperPipe'}
  17779. */
  17780. var LowerCasePipe = (function () {
  17781. function LowerCasePipe() {
  17782. }
  17783. LowerCasePipe.prototype.transform = function (value, args) {
  17784. if (args === void 0) { args = null; }
  17785. if (lang_1.isBlank(value))
  17786. return value;
  17787. if (!lang_1.isString(value)) {
  17788. throw new invalid_pipe_argument_exception_1.InvalidPipeArgumentException(LowerCasePipe, value);
  17789. }
  17790. return value.toLowerCase();
  17791. };
  17792. LowerCasePipe = __decorate([
  17793. lang_1.CONST(),
  17794. core_1.Pipe({ name: 'lowercase' }),
  17795. core_1.Injectable(),
  17796. __metadata('design:paramtypes', [])
  17797. ], LowerCasePipe);
  17798. return LowerCasePipe;
  17799. })();
  17800. exports.LowerCasePipe = LowerCasePipe;
  17801. /***/ },
  17802. /* 110 */
  17803. /***/ function(module, exports, __webpack_require__) {
  17804. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  17805. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  17806. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  17807. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  17808. return c > 3 && r && Object.defineProperty(target, key, r), r;
  17809. };
  17810. var __metadata = (this && this.__metadata) || function (k, v) {
  17811. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  17812. };
  17813. var lang_1 = __webpack_require__(5);
  17814. var core_1 = __webpack_require__(2);
  17815. /**
  17816. * Transforms any input value using `JSON.stringify`. Useful for debugging.
  17817. *
  17818. * ### Example
  17819. * {@example core/pipes/ts/json_pipe/json_pipe_example.ts region='JsonPipe'}
  17820. */
  17821. var JsonPipe = (function () {
  17822. function JsonPipe() {
  17823. }
  17824. JsonPipe.prototype.transform = function (value, args) {
  17825. if (args === void 0) { args = null; }
  17826. return lang_1.Json.stringify(value);
  17827. };
  17828. JsonPipe = __decorate([
  17829. lang_1.CONST(),
  17830. core_1.Pipe({ name: 'json', pure: false }),
  17831. core_1.Injectable(),
  17832. __metadata('design:paramtypes', [])
  17833. ], JsonPipe);
  17834. return JsonPipe;
  17835. })();
  17836. exports.JsonPipe = JsonPipe;
  17837. /***/ },
  17838. /* 111 */
  17839. /***/ function(module, exports, __webpack_require__) {
  17840. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  17841. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  17842. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  17843. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  17844. return c > 3 && r && Object.defineProperty(target, key, r), r;
  17845. };
  17846. var __metadata = (this && this.__metadata) || function (k, v) {
  17847. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  17848. };
  17849. var lang_1 = __webpack_require__(5);
  17850. var exceptions_1 = __webpack_require__(14);
  17851. var collection_1 = __webpack_require__(12);
  17852. var core_1 = __webpack_require__(2);
  17853. var invalid_pipe_argument_exception_1 = __webpack_require__(107);
  17854. /**
  17855. * Creates a new List or String containing only a subset (slice) of the
  17856. * elements.
  17857. *
  17858. * The starting index of the subset to return is specified by the `start` parameter.
  17859. *
  17860. * The ending index of the subset to return is specified by the optional `end` parameter.
  17861. *
  17862. * ### Usage
  17863. *
  17864. * expression | slice:start[:end]
  17865. *
  17866. * All behavior is based on the expected behavior of the JavaScript API
  17867. * Array.prototype.slice() and String.prototype.slice()
  17868. *
  17869. * Where the input expression is a [List] or [String], and `start` is:
  17870. *
  17871. * - **a positive integer**: return the item at _start_ index and all items after
  17872. * in the list or string expression.
  17873. * - **a negative integer**: return the item at _start_ index from the end and all items after
  17874. * in the list or string expression.
  17875. * - **`|start|` greater than the size of the expression**: return an empty list or string.
  17876. * - **`|start|` negative greater than the size of the expression**: return entire list or
  17877. * string expression.
  17878. *
  17879. * and where `end` is:
  17880. *
  17881. * - **omitted**: return all items until the end of the input
  17882. * - **a positive integer**: return all items before _end_ index of the list or string
  17883. * expression.
  17884. * - **a negative integer**: return all items before _end_ index from the end of the list
  17885. * or string expression.
  17886. *
  17887. * When operating on a [List], the returned list is always a copy even when all
  17888. * the elements are being returned.
  17889. *
  17890. * ## List Example
  17891. *
  17892. * This `ngFor` example:
  17893. *
  17894. * {@example core/pipes/ts/slice_pipe/slice_pipe_example.ts region='SlicePipe_list'}
  17895. *
  17896. * produces the following:
  17897. *
  17898. * <li>b</li>
  17899. * <li>c</li>
  17900. *
  17901. * ## String Examples
  17902. *
  17903. * {@example core/pipes/ts/slice_pipe/slice_pipe_example.ts region='SlicePipe_string'}
  17904. */
  17905. var SlicePipe = (function () {
  17906. function SlicePipe() {
  17907. }
  17908. SlicePipe.prototype.transform = function (value, args) {
  17909. if (args === void 0) { args = null; }
  17910. if (lang_1.isBlank(args) || args.length == 0) {
  17911. throw new exceptions_1.BaseException('Slice pipe requires one argument');
  17912. }
  17913. if (!this.supports(value)) {
  17914. throw new invalid_pipe_argument_exception_1.InvalidPipeArgumentException(SlicePipe, value);
  17915. }
  17916. if (lang_1.isBlank(value))
  17917. return value;
  17918. var start = args[0];
  17919. var end = args.length > 1 ? args[1] : null;
  17920. if (lang_1.isString(value)) {
  17921. return lang_1.StringWrapper.slice(value, start, end);
  17922. }
  17923. return collection_1.ListWrapper.slice(value, start, end);
  17924. };
  17925. SlicePipe.prototype.supports = function (obj) { return lang_1.isString(obj) || lang_1.isArray(obj); };
  17926. SlicePipe = __decorate([
  17927. core_1.Pipe({ name: 'slice', pure: false }),
  17928. core_1.Injectable(),
  17929. __metadata('design:paramtypes', [])
  17930. ], SlicePipe);
  17931. return SlicePipe;
  17932. })();
  17933. exports.SlicePipe = SlicePipe;
  17934. /***/ },
  17935. /* 112 */
  17936. /***/ function(module, exports, __webpack_require__) {
  17937. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  17938. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  17939. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  17940. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  17941. return c > 3 && r && Object.defineProperty(target, key, r), r;
  17942. };
  17943. var __metadata = (this && this.__metadata) || function (k, v) {
  17944. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  17945. };
  17946. var lang_1 = __webpack_require__(5);
  17947. var intl_1 = __webpack_require__(113);
  17948. var core_1 = __webpack_require__(2);
  17949. var collection_1 = __webpack_require__(12);
  17950. var invalid_pipe_argument_exception_1 = __webpack_require__(107);
  17951. // TODO: move to a global configurable location along with other i18n components.
  17952. var defaultLocale = 'en-US';
  17953. /**
  17954. * Formats a date value to a string based on the requested format.
  17955. *
  17956. * WARNINGS:
  17957. * - this pipe is marked as pure hence it will not be re-evaluated when the input is mutated.
  17958. * Instead users should treat the date as an immutable object and change the reference when the
  17959. * pipe needs to re-run (this is to avoid reformatting the date on every change detection run
  17960. * which would be an expensive operation).
  17961. * - this pipe uses the Internationalization API. Therefore it is only reliable in Chrome and Opera
  17962. * browsers.
  17963. *
  17964. * ## Usage
  17965. *
  17966. * expression | date[:format]
  17967. *
  17968. * where `expression` is a date object or a number (milliseconds since UTC epoch) and
  17969. * `format` indicates which date/time components to include:
  17970. *
  17971. * | Component | Symbol | Short Form | Long Form | Numeric | 2-digit |
  17972. * |-----------|:------:|--------------|-------------------|-----------|-----------|
  17973. * | era | G | G (AD) | GGGG (Anno Domini)| - | - |
  17974. * | year | y | - | - | y (2015) | yy (15) |
  17975. * | month | M | MMM (Sep) | MMMM (September) | M (9) | MM (09) |
  17976. * | day | d | - | - | d (3) | dd (03) |
  17977. * | weekday | E | EEE (Sun) | EEEE (Sunday) | - | - |
  17978. * | hour | j | - | - | j (13) | jj (13) |
  17979. * | hour12 | h | - | - | h (1 PM) | hh (01 PM)|
  17980. * | hour24 | H | - | - | H (13) | HH (13) |
  17981. * | minute | m | - | - | m (5) | mm (05) |
  17982. * | second | s | - | - | s (9) | ss (09) |
  17983. * | timezone | z | - | z (Pacific Standard Time)| - | - |
  17984. * | timezone | Z | Z (GMT-8:00) | - | - | - |
  17985. *
  17986. * In javascript, only the components specified will be respected (not the ordering,
  17987. * punctuations, ...) and details of the formatting will be dependent on the locale.
  17988. * On the other hand in Dart version, you can also include quoted text as well as some extra
  17989. * date/time components such as quarter. For more information see:
  17990. * https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/intl/intl.DateFormat.
  17991. *
  17992. * `format` can also be one of the following predefined formats:
  17993. *
  17994. * - `'medium'`: equivalent to `'yMMMdjms'` (e.g. Sep 3, 2010, 12:05:08 PM for en-US)
  17995. * - `'short'`: equivalent to `'yMdjm'` (e.g. 9/3/2010, 12:05 PM for en-US)
  17996. * - `'fullDate'`: equivalent to `'yMMMMEEEEd'` (e.g. Friday, September 3, 2010 for en-US)
  17997. * - `'longDate'`: equivalent to `'yMMMMd'` (e.g. September 3, 2010)
  17998. * - `'mediumDate'`: equivalent to `'yMMMd'` (e.g. Sep 3, 2010 for en-US)
  17999. * - `'shortDate'`: equivalent to `'yMd'` (e.g. 9/3/2010 for en-US)
  18000. * - `'mediumTime'`: equivalent to `'jms'` (e.g. 12:05:08 PM for en-US)
  18001. * - `'shortTime'`: equivalent to `'jm'` (e.g. 12:05 PM for en-US)
  18002. *
  18003. * Timezone of the formatted text will be the local system timezone of the end-users machine.
  18004. *
  18005. * ### Examples
  18006. *
  18007. * Assuming `dateObj` is (year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11)
  18008. * in the _local_ time and locale is 'en-US':
  18009. *
  18010. * ```
  18011. * {{ dateObj | date }} // output is 'Jun 15, 2015'
  18012. * {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'
  18013. * {{ dateObj | date:'shortTime' }} // output is '9:43 PM'
  18014. * {{ dateObj | date:'mmss' }} // output is '43:11'
  18015. * ```
  18016. *
  18017. * {@example core/pipes/ts/date_pipe/date_pipe_example.ts region='DatePipe'}
  18018. */
  18019. var DatePipe = (function () {
  18020. function DatePipe() {
  18021. }
  18022. DatePipe.prototype.transform = function (value, args) {
  18023. if (lang_1.isBlank(value))
  18024. return null;
  18025. if (!this.supports(value)) {
  18026. throw new invalid_pipe_argument_exception_1.InvalidPipeArgumentException(DatePipe, value);
  18027. }
  18028. var pattern = lang_1.isPresent(args) && args.length > 0 ? args[0] : 'mediumDate';
  18029. if (lang_1.isNumber(value)) {
  18030. value = lang_1.DateWrapper.fromMillis(value);
  18031. }
  18032. if (collection_1.StringMapWrapper.contains(DatePipe._ALIASES, pattern)) {
  18033. pattern = collection_1.StringMapWrapper.get(DatePipe._ALIASES, pattern);
  18034. }
  18035. return intl_1.DateFormatter.format(value, defaultLocale, pattern);
  18036. };
  18037. DatePipe.prototype.supports = function (obj) { return lang_1.isDate(obj) || lang_1.isNumber(obj); };
  18038. /** @internal */
  18039. DatePipe._ALIASES = {
  18040. 'medium': 'yMMMdjms',
  18041. 'short': 'yMdjm',
  18042. 'fullDate': 'yMMMMEEEEd',
  18043. 'longDate': 'yMMMMd',
  18044. 'mediumDate': 'yMMMd',
  18045. 'shortDate': 'yMd',
  18046. 'mediumTime': 'jms',
  18047. 'shortTime': 'jm'
  18048. };
  18049. DatePipe = __decorate([
  18050. lang_1.CONST(),
  18051. core_1.Pipe({ name: 'date', pure: true }),
  18052. core_1.Injectable(),
  18053. __metadata('design:paramtypes', [])
  18054. ], DatePipe);
  18055. return DatePipe;
  18056. })();
  18057. exports.DatePipe = DatePipe;
  18058. /***/ },
  18059. /* 113 */
  18060. /***/ function(module, exports) {
  18061. (function (NumberFormatStyle) {
  18062. NumberFormatStyle[NumberFormatStyle["Decimal"] = 0] = "Decimal";
  18063. NumberFormatStyle[NumberFormatStyle["Percent"] = 1] = "Percent";
  18064. NumberFormatStyle[NumberFormatStyle["Currency"] = 2] = "Currency";
  18065. })(exports.NumberFormatStyle || (exports.NumberFormatStyle = {}));
  18066. var NumberFormatStyle = exports.NumberFormatStyle;
  18067. var NumberFormatter = (function () {
  18068. function NumberFormatter() {
  18069. }
  18070. NumberFormatter.format = function (num, locale, style, _a) {
  18071. var _b = _a === void 0 ? {} : _a, _c = _b.minimumIntegerDigits, minimumIntegerDigits = _c === void 0 ? 1 : _c, _d = _b.minimumFractionDigits, minimumFractionDigits = _d === void 0 ? 0 : _d, _e = _b.maximumFractionDigits, maximumFractionDigits = _e === void 0 ? 3 : _e, currency = _b.currency, _f = _b.currencyAsSymbol, currencyAsSymbol = _f === void 0 ? false : _f;
  18072. var intlOptions = {
  18073. minimumIntegerDigits: minimumIntegerDigits,
  18074. minimumFractionDigits: minimumFractionDigits,
  18075. maximumFractionDigits: maximumFractionDigits
  18076. };
  18077. intlOptions.style = NumberFormatStyle[style].toLowerCase();
  18078. if (style == NumberFormatStyle.Currency) {
  18079. intlOptions.currency = currency;
  18080. intlOptions.currencyDisplay = currencyAsSymbol ? 'symbol' : 'code';
  18081. }
  18082. return new Intl.NumberFormat(locale, intlOptions).format(num);
  18083. };
  18084. return NumberFormatter;
  18085. })();
  18086. exports.NumberFormatter = NumberFormatter;
  18087. function digitCondition(len) {
  18088. return len == 2 ? '2-digit' : 'numeric';
  18089. }
  18090. function nameCondition(len) {
  18091. return len < 4 ? 'short' : 'long';
  18092. }
  18093. function extractComponents(pattern) {
  18094. var ret = {};
  18095. var i = 0, j;
  18096. while (i < pattern.length) {
  18097. j = i;
  18098. while (j < pattern.length && pattern[j] == pattern[i])
  18099. j++;
  18100. var len = j - i;
  18101. switch (pattern[i]) {
  18102. case 'G':
  18103. ret.era = nameCondition(len);
  18104. break;
  18105. case 'y':
  18106. ret.year = digitCondition(len);
  18107. break;
  18108. case 'M':
  18109. if (len >= 3)
  18110. ret.month = nameCondition(len);
  18111. else
  18112. ret.month = digitCondition(len);
  18113. break;
  18114. case 'd':
  18115. ret.day = digitCondition(len);
  18116. break;
  18117. case 'E':
  18118. ret.weekday = nameCondition(len);
  18119. break;
  18120. case 'j':
  18121. ret.hour = digitCondition(len);
  18122. break;
  18123. case 'h':
  18124. ret.hour = digitCondition(len);
  18125. ret.hour12 = true;
  18126. break;
  18127. case 'H':
  18128. ret.hour = digitCondition(len);
  18129. ret.hour12 = false;
  18130. break;
  18131. case 'm':
  18132. ret.minute = digitCondition(len);
  18133. break;
  18134. case 's':
  18135. ret.second = digitCondition(len);
  18136. break;
  18137. case 'z':
  18138. ret.timeZoneName = 'long';
  18139. break;
  18140. case 'Z':
  18141. ret.timeZoneName = 'short';
  18142. break;
  18143. }
  18144. i = j;
  18145. }
  18146. return ret;
  18147. }
  18148. var dateFormatterCache = new Map();
  18149. var DateFormatter = (function () {
  18150. function DateFormatter() {
  18151. }
  18152. DateFormatter.format = function (date, locale, pattern) {
  18153. var key = locale + pattern;
  18154. if (dateFormatterCache.has(key)) {
  18155. return dateFormatterCache.get(key).format(date);
  18156. }
  18157. var formatter = new Intl.DateTimeFormat(locale, extractComponents(pattern));
  18158. dateFormatterCache.set(key, formatter);
  18159. return formatter.format(date);
  18160. };
  18161. return DateFormatter;
  18162. })();
  18163. exports.DateFormatter = DateFormatter;
  18164. /***/ },
  18165. /* 114 */
  18166. /***/ function(module, exports, __webpack_require__) {
  18167. var __extends = (this && this.__extends) || function (d, b) {
  18168. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  18169. function __() { this.constructor = d; }
  18170. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  18171. };
  18172. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  18173. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  18174. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  18175. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  18176. return c > 3 && r && Object.defineProperty(target, key, r), r;
  18177. };
  18178. var __metadata = (this && this.__metadata) || function (k, v) {
  18179. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  18180. };
  18181. var lang_1 = __webpack_require__(5);
  18182. var exceptions_1 = __webpack_require__(14);
  18183. var intl_1 = __webpack_require__(113);
  18184. var core_1 = __webpack_require__(2);
  18185. var collection_1 = __webpack_require__(12);
  18186. var invalid_pipe_argument_exception_1 = __webpack_require__(107);
  18187. var defaultLocale = 'en-US';
  18188. var _re = lang_1.RegExpWrapper.create('^(\\d+)?\\.((\\d+)(\\-(\\d+))?)?$');
  18189. /**
  18190. * Internal base class for numeric pipes.
  18191. */
  18192. var NumberPipe = (function () {
  18193. function NumberPipe() {
  18194. }
  18195. /** @internal */
  18196. NumberPipe._format = function (value, style, digits, currency, currencyAsSymbol) {
  18197. if (currency === void 0) { currency = null; }
  18198. if (currencyAsSymbol === void 0) { currencyAsSymbol = false; }
  18199. if (lang_1.isBlank(value))
  18200. return null;
  18201. if (!lang_1.isNumber(value)) {
  18202. throw new invalid_pipe_argument_exception_1.InvalidPipeArgumentException(NumberPipe, value);
  18203. }
  18204. var minInt = 1, minFraction = 0, maxFraction = 3;
  18205. if (lang_1.isPresent(digits)) {
  18206. var parts = lang_1.RegExpWrapper.firstMatch(_re, digits);
  18207. if (lang_1.isBlank(parts)) {
  18208. throw new exceptions_1.BaseException(digits + " is not a valid digit info for number pipes");
  18209. }
  18210. if (lang_1.isPresent(parts[1])) {
  18211. minInt = lang_1.NumberWrapper.parseIntAutoRadix(parts[1]);
  18212. }
  18213. if (lang_1.isPresent(parts[3])) {
  18214. minFraction = lang_1.NumberWrapper.parseIntAutoRadix(parts[3]);
  18215. }
  18216. if (lang_1.isPresent(parts[5])) {
  18217. maxFraction = lang_1.NumberWrapper.parseIntAutoRadix(parts[5]);
  18218. }
  18219. }
  18220. return intl_1.NumberFormatter.format(value, defaultLocale, style, {
  18221. minimumIntegerDigits: minInt,
  18222. minimumFractionDigits: minFraction,
  18223. maximumFractionDigits: maxFraction,
  18224. currency: currency,
  18225. currencyAsSymbol: currencyAsSymbol
  18226. });
  18227. };
  18228. NumberPipe = __decorate([
  18229. lang_1.CONST(),
  18230. core_1.Injectable(),
  18231. __metadata('design:paramtypes', [])
  18232. ], NumberPipe);
  18233. return NumberPipe;
  18234. })();
  18235. exports.NumberPipe = NumberPipe;
  18236. /**
  18237. * WARNING: this pipe uses the Internationalization API.
  18238. * Therefore it is only reliable in Chrome and Opera browsers.
  18239. *
  18240. * Formats a number as local text. i.e. group sizing and separator and other locale-specific
  18241. * configurations are based on the active locale.
  18242. *
  18243. * ### Usage
  18244. *
  18245. * expression | number[:digitInfo]
  18246. *
  18247. * where `expression` is a number and `digitInfo` has the following format:
  18248. *
  18249. * {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
  18250. *
  18251. * - minIntegerDigits is the minimum number of integer digits to use. Defaults to 1.
  18252. * - minFractionDigits is the minimum number of digits after fraction. Defaults to 0.
  18253. * - maxFractionDigits is the maximum number of digits after fraction. Defaults to 3.
  18254. *
  18255. * For more information on the acceptable range for each of these numbers and other
  18256. * details see your native internationalization library.
  18257. *
  18258. * ### Example
  18259. *
  18260. * {@example core/pipes/ts/number_pipe/number_pipe_example.ts region='NumberPipe'}
  18261. */
  18262. var DecimalPipe = (function (_super) {
  18263. __extends(DecimalPipe, _super);
  18264. function DecimalPipe() {
  18265. _super.apply(this, arguments);
  18266. }
  18267. DecimalPipe.prototype.transform = function (value, args) {
  18268. var digits = collection_1.ListWrapper.first(args);
  18269. return NumberPipe._format(value, intl_1.NumberFormatStyle.Decimal, digits);
  18270. };
  18271. DecimalPipe = __decorate([
  18272. lang_1.CONST(),
  18273. core_1.Pipe({ name: 'number' }),
  18274. core_1.Injectable(),
  18275. __metadata('design:paramtypes', [])
  18276. ], DecimalPipe);
  18277. return DecimalPipe;
  18278. })(NumberPipe);
  18279. exports.DecimalPipe = DecimalPipe;
  18280. /**
  18281. * WARNING: this pipe uses the Internationalization API.
  18282. * Therefore it is only reliable in Chrome and Opera browsers.
  18283. *
  18284. * Formats a number as local percent.
  18285. *
  18286. * ### Usage
  18287. *
  18288. * expression | percent[:digitInfo]
  18289. *
  18290. * For more information about `digitInfo` see {@link DecimalPipe}
  18291. *
  18292. * ### Example
  18293. *
  18294. * {@example core/pipes/ts/number_pipe/number_pipe_example.ts region='PercentPipe'}
  18295. */
  18296. var PercentPipe = (function (_super) {
  18297. __extends(PercentPipe, _super);
  18298. function PercentPipe() {
  18299. _super.apply(this, arguments);
  18300. }
  18301. PercentPipe.prototype.transform = function (value, args) {
  18302. var digits = collection_1.ListWrapper.first(args);
  18303. return NumberPipe._format(value, intl_1.NumberFormatStyle.Percent, digits);
  18304. };
  18305. PercentPipe = __decorate([
  18306. lang_1.CONST(),
  18307. core_1.Pipe({ name: 'percent' }),
  18308. core_1.Injectable(),
  18309. __metadata('design:paramtypes', [])
  18310. ], PercentPipe);
  18311. return PercentPipe;
  18312. })(NumberPipe);
  18313. exports.PercentPipe = PercentPipe;
  18314. /**
  18315. * WARNING: this pipe uses the Internationalization API.
  18316. * Therefore it is only reliable in Chrome and Opera browsers.
  18317. *
  18318. * Formats a number as local currency.
  18319. *
  18320. * ### Usage
  18321. *
  18322. * expression | currency[:currencyCode[:symbolDisplay[:digitInfo]]]
  18323. *
  18324. * where `currencyCode` is the ISO 4217 currency code, such as "USD" for the US dollar and
  18325. * "EUR" for the euro. `symbolDisplay` is a boolean indicating whether to use the currency
  18326. * symbol (e.g. $) or the currency code (e.g. USD) in the output. The default for this value
  18327. * is `false`.
  18328. * For more information about `digitInfo` see {@link DecimalPipe}
  18329. *
  18330. * ### Example
  18331. *
  18332. * {@example core/pipes/ts/number_pipe/number_pipe_example.ts region='CurrencyPipe'}
  18333. */
  18334. var CurrencyPipe = (function (_super) {
  18335. __extends(CurrencyPipe, _super);
  18336. function CurrencyPipe() {
  18337. _super.apply(this, arguments);
  18338. }
  18339. CurrencyPipe.prototype.transform = function (value, args) {
  18340. var currencyCode = lang_1.isPresent(args) && args.length > 0 ? args[0] : 'USD';
  18341. var symbolDisplay = lang_1.isPresent(args) && args.length > 1 ? args[1] : false;
  18342. var digits = lang_1.isPresent(args) && args.length > 2 ? args[2] : null;
  18343. return NumberPipe._format(value, intl_1.NumberFormatStyle.Currency, digits, currencyCode, symbolDisplay);
  18344. };
  18345. CurrencyPipe = __decorate([
  18346. lang_1.CONST(),
  18347. core_1.Pipe({ name: 'currency' }),
  18348. core_1.Injectable(),
  18349. __metadata('design:paramtypes', [])
  18350. ], CurrencyPipe);
  18351. return CurrencyPipe;
  18352. })(NumberPipe);
  18353. exports.CurrencyPipe = CurrencyPipe;
  18354. /***/ },
  18355. /* 115 */
  18356. /***/ function(module, exports, __webpack_require__) {
  18357. function __export(m) {
  18358. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  18359. }
  18360. /**
  18361. * @module
  18362. * @description
  18363. * Common directives shipped with Angular.
  18364. */
  18365. var ng_class_1 = __webpack_require__(116);
  18366. exports.NgClass = ng_class_1.NgClass;
  18367. var ng_for_1 = __webpack_require__(117);
  18368. exports.NgFor = ng_for_1.NgFor;
  18369. var ng_if_1 = __webpack_require__(118);
  18370. exports.NgIf = ng_if_1.NgIf;
  18371. var ng_style_1 = __webpack_require__(119);
  18372. exports.NgStyle = ng_style_1.NgStyle;
  18373. var ng_switch_1 = __webpack_require__(120);
  18374. exports.NgSwitch = ng_switch_1.NgSwitch;
  18375. exports.NgSwitchWhen = ng_switch_1.NgSwitchWhen;
  18376. exports.NgSwitchDefault = ng_switch_1.NgSwitchDefault;
  18377. __export(__webpack_require__(121));
  18378. var core_directives_1 = __webpack_require__(122);
  18379. exports.CORE_DIRECTIVES = core_directives_1.CORE_DIRECTIVES;
  18380. /***/ },
  18381. /* 116 */
  18382. /***/ function(module, exports, __webpack_require__) {
  18383. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  18384. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  18385. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  18386. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  18387. return c > 3 && r && Object.defineProperty(target, key, r), r;
  18388. };
  18389. var __metadata = (this && this.__metadata) || function (k, v) {
  18390. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  18391. };
  18392. var lang_1 = __webpack_require__(5);
  18393. var core_1 = __webpack_require__(2);
  18394. var collection_1 = __webpack_require__(12);
  18395. /**
  18396. * The `NgClass` directive conditionally adds and removes CSS classes on an HTML element based on
  18397. * an expression's evaluation result.
  18398. *
  18399. * The result of an expression evaluation is interpreted differently depending on type of
  18400. * the expression evaluation result:
  18401. * - `string` - all the CSS classes listed in a string (space delimited) are added
  18402. * - `Array` - all the CSS classes (Array elements) are added
  18403. * - `Object` - each key corresponds to a CSS class name while values are interpreted as expressions
  18404. * evaluating to `Boolean`. If a given expression evaluates to `true` a corresponding CSS class
  18405. * is added - otherwise it is removed.
  18406. *
  18407. * While the `NgClass` directive can interpret expressions evaluating to `string`, `Array`
  18408. * or `Object`, the `Object`-based version is the most often used and has an advantage of keeping
  18409. * all the CSS class names in a template.
  18410. *
  18411. * ### Example ([live demo](http://plnkr.co/edit/a4YdtmWywhJ33uqfpPPn?p=preview)):
  18412. *
  18413. * ```
  18414. * import {Component} from 'angular2/core';
  18415. * import {NgClass} from 'angular2/common';
  18416. *
  18417. * @Component({
  18418. * selector: 'toggle-button',
  18419. * inputs: ['isDisabled'],
  18420. * template: `
  18421. * <div class="button" [ngClass]="{active: isOn, disabled: isDisabled}"
  18422. * (click)="toggle(!isOn)">
  18423. * Click me!
  18424. * </div>`,
  18425. * styles: [`
  18426. * .button {
  18427. * width: 120px;
  18428. * border: medium solid black;
  18429. * }
  18430. *
  18431. * .active {
  18432. * background-color: red;
  18433. * }
  18434. *
  18435. * .disabled {
  18436. * color: gray;
  18437. * border: medium solid gray;
  18438. * }
  18439. * `]
  18440. * directives: [NgClass]
  18441. * })
  18442. * class ToggleButton {
  18443. * isOn = false;
  18444. * isDisabled = false;
  18445. *
  18446. * toggle(newState) {
  18447. * if (!this.isDisabled) {
  18448. * this.isOn = newState;
  18449. * }
  18450. * }
  18451. * }
  18452. * ```
  18453. */
  18454. var NgClass = (function () {
  18455. function NgClass(_iterableDiffers, _keyValueDiffers, _ngEl, _renderer) {
  18456. this._iterableDiffers = _iterableDiffers;
  18457. this._keyValueDiffers = _keyValueDiffers;
  18458. this._ngEl = _ngEl;
  18459. this._renderer = _renderer;
  18460. this._initialClasses = [];
  18461. }
  18462. Object.defineProperty(NgClass.prototype, "initialClasses", {
  18463. set: function (v) {
  18464. this._applyInitialClasses(true);
  18465. this._initialClasses = lang_1.isPresent(v) && lang_1.isString(v) ? v.split(' ') : [];
  18466. this._applyInitialClasses(false);
  18467. this._applyClasses(this._rawClass, false);
  18468. },
  18469. enumerable: true,
  18470. configurable: true
  18471. });
  18472. Object.defineProperty(NgClass.prototype, "rawClass", {
  18473. set: function (v) {
  18474. this._cleanupClasses(this._rawClass);
  18475. if (lang_1.isString(v)) {
  18476. v = v.split(' ');
  18477. }
  18478. this._rawClass = v;
  18479. if (lang_1.isPresent(v)) {
  18480. if (collection_1.isListLikeIterable(v)) {
  18481. this._differ = this._iterableDiffers.find(v).create(null);
  18482. this._mode = 'iterable';
  18483. }
  18484. else {
  18485. this._differ = this._keyValueDiffers.find(v).create(null);
  18486. this._mode = 'keyValue';
  18487. }
  18488. }
  18489. else {
  18490. this._differ = null;
  18491. }
  18492. },
  18493. enumerable: true,
  18494. configurable: true
  18495. });
  18496. NgClass.prototype.ngDoCheck = function () {
  18497. if (lang_1.isPresent(this._differ)) {
  18498. var changes = this._differ.diff(this._rawClass);
  18499. if (lang_1.isPresent(changes)) {
  18500. if (this._mode == 'iterable') {
  18501. this._applyIterableChanges(changes);
  18502. }
  18503. else {
  18504. this._applyKeyValueChanges(changes);
  18505. }
  18506. }
  18507. }
  18508. };
  18509. NgClass.prototype.ngOnDestroy = function () { this._cleanupClasses(this._rawClass); };
  18510. NgClass.prototype._cleanupClasses = function (rawClassVal) {
  18511. this._applyClasses(rawClassVal, true);
  18512. this._applyInitialClasses(false);
  18513. };
  18514. NgClass.prototype._applyKeyValueChanges = function (changes) {
  18515. var _this = this;
  18516. changes.forEachAddedItem(function (record) { _this._toggleClass(record.key, record.currentValue); });
  18517. changes.forEachChangedItem(function (record) { _this._toggleClass(record.key, record.currentValue); });
  18518. changes.forEachRemovedItem(function (record) {
  18519. if (record.previousValue) {
  18520. _this._toggleClass(record.key, false);
  18521. }
  18522. });
  18523. };
  18524. NgClass.prototype._applyIterableChanges = function (changes) {
  18525. var _this = this;
  18526. changes.forEachAddedItem(function (record) { _this._toggleClass(record.item, true); });
  18527. changes.forEachRemovedItem(function (record) { _this._toggleClass(record.item, false); });
  18528. };
  18529. NgClass.prototype._applyInitialClasses = function (isCleanup) {
  18530. var _this = this;
  18531. this._initialClasses.forEach(function (className) { return _this._toggleClass(className, !isCleanup); });
  18532. };
  18533. NgClass.prototype._applyClasses = function (rawClassVal, isCleanup) {
  18534. var _this = this;
  18535. if (lang_1.isPresent(rawClassVal)) {
  18536. if (lang_1.isArray(rawClassVal)) {
  18537. rawClassVal.forEach(function (className) { return _this._toggleClass(className, !isCleanup); });
  18538. }
  18539. else if (rawClassVal instanceof Set) {
  18540. rawClassVal.forEach(function (className) { return _this._toggleClass(className, !isCleanup); });
  18541. }
  18542. else {
  18543. collection_1.StringMapWrapper.forEach(rawClassVal, function (expVal, className) {
  18544. if (expVal)
  18545. _this._toggleClass(className, !isCleanup);
  18546. });
  18547. }
  18548. }
  18549. };
  18550. NgClass.prototype._toggleClass = function (className, enabled) {
  18551. className = className.trim();
  18552. if (className.length > 0) {
  18553. if (className.indexOf(' ') > -1) {
  18554. var classes = className.split(/\s+/g);
  18555. for (var i = 0, len = classes.length; i < len; i++) {
  18556. this._renderer.setElementClass(this._ngEl, classes[i], enabled);
  18557. }
  18558. }
  18559. else {
  18560. this._renderer.setElementClass(this._ngEl, className, enabled);
  18561. }
  18562. }
  18563. };
  18564. NgClass = __decorate([
  18565. core_1.Directive({ selector: '[ngClass]', inputs: ['rawClass: ngClass', 'initialClasses: class'] }),
  18566. __metadata('design:paramtypes', [core_1.IterableDiffers, core_1.KeyValueDiffers, core_1.ElementRef, core_1.Renderer])
  18567. ], NgClass);
  18568. return NgClass;
  18569. })();
  18570. exports.NgClass = NgClass;
  18571. /***/ },
  18572. /* 117 */
  18573. /***/ function(module, exports, __webpack_require__) {
  18574. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  18575. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  18576. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  18577. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  18578. return c > 3 && r && Object.defineProperty(target, key, r), r;
  18579. };
  18580. var __metadata = (this && this.__metadata) || function (k, v) {
  18581. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  18582. };
  18583. var core_1 = __webpack_require__(2);
  18584. var lang_1 = __webpack_require__(5);
  18585. /**
  18586. * The `NgFor` directive instantiates a template once per item from an iterable. The context for
  18587. * each instantiated template inherits from the outer context with the given loop variable set
  18588. * to the current item from the iterable.
  18589. *
  18590. * # Local Variables
  18591. *
  18592. * `NgFor` provides several exported values that can be aliased to local variables:
  18593. *
  18594. * * `index` will be set to the current loop iteration for each template context.
  18595. * * `last` will be set to a boolean value indicating whether the item is the last one in the
  18596. * iteration.
  18597. * * `even` will be set to a boolean value indicating whether this item has an even index.
  18598. * * `odd` will be set to a boolean value indicating whether this item has an odd index.
  18599. *
  18600. * # Change Propagation
  18601. *
  18602. * When the contents of the iterator changes, `NgFor` makes the corresponding changes to the DOM:
  18603. *
  18604. * * When an item is added, a new instance of the template is added to the DOM.
  18605. * * When an item is removed, its template instance is removed from the DOM.
  18606. * * When items are reordered, their respective templates are reordered in the DOM.
  18607. * * Otherwise, the DOM element for that item will remain the same.
  18608. *
  18609. * Angular uses object identity to track insertions and deletions within the iterator and reproduce
  18610. * those changes in the DOM. This has important implications for animations and any stateful
  18611. * controls
  18612. * (such as `<input>` elements which accept user input) that are present. Inserted rows can be
  18613. * animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state such
  18614. * as user input.
  18615. *
  18616. * It is possible for the identities of elements in the iterator to change while the data does not.
  18617. * This can happen, for example, if the iterator produced from an RPC to the server, and that
  18618. * RPC is re-run. Even if the data hasn't changed, the second response will produce objects with
  18619. * different identities, and Angular will tear down the entire DOM and rebuild it (as if all old
  18620. * elements were deleted and all new elements inserted). This is an expensive operation and should
  18621. * be avoided if possible.
  18622. *
  18623. * # Syntax
  18624. *
  18625. * - `<li *ngFor="#item of items; #i = index">...</li>`
  18626. * - `<li template="ngFor #item of items; #i = index">...</li>`
  18627. * - `<template ngFor #item [ngForOf]="items" #i="index"><li>...</li></template>`
  18628. *
  18629. * ### Example
  18630. *
  18631. * See a [live demo](http://plnkr.co/edit/KVuXxDp0qinGDyo307QW?p=preview) for a more detailed
  18632. * example.
  18633. */
  18634. var NgFor = (function () {
  18635. function NgFor(_viewContainer, _templateRef, _iterableDiffers, _cdr) {
  18636. this._viewContainer = _viewContainer;
  18637. this._templateRef = _templateRef;
  18638. this._iterableDiffers = _iterableDiffers;
  18639. this._cdr = _cdr;
  18640. }
  18641. Object.defineProperty(NgFor.prototype, "ngForOf", {
  18642. set: function (value) {
  18643. this._ngForOf = value;
  18644. if (lang_1.isBlank(this._differ) && lang_1.isPresent(value)) {
  18645. this._differ = this._iterableDiffers.find(value).create(this._cdr);
  18646. }
  18647. },
  18648. enumerable: true,
  18649. configurable: true
  18650. });
  18651. Object.defineProperty(NgFor.prototype, "ngForTemplate", {
  18652. set: function (value) {
  18653. if (lang_1.isPresent(value)) {
  18654. this._templateRef = value;
  18655. }
  18656. },
  18657. enumerable: true,
  18658. configurable: true
  18659. });
  18660. NgFor.prototype.ngDoCheck = function () {
  18661. if (lang_1.isPresent(this._differ)) {
  18662. var changes = this._differ.diff(this._ngForOf);
  18663. if (lang_1.isPresent(changes))
  18664. this._applyChanges(changes);
  18665. }
  18666. };
  18667. NgFor.prototype._applyChanges = function (changes) {
  18668. // TODO(rado): check if change detection can produce a change record that is
  18669. // easier to consume than current.
  18670. var recordViewTuples = [];
  18671. changes.forEachRemovedItem(function (removedRecord) {
  18672. return recordViewTuples.push(new RecordViewTuple(removedRecord, null));
  18673. });
  18674. changes.forEachMovedItem(function (movedRecord) {
  18675. return recordViewTuples.push(new RecordViewTuple(movedRecord, null));
  18676. });
  18677. var insertTuples = this._bulkRemove(recordViewTuples);
  18678. changes.forEachAddedItem(function (addedRecord) {
  18679. return insertTuples.push(new RecordViewTuple(addedRecord, null));
  18680. });
  18681. this._bulkInsert(insertTuples);
  18682. for (var i = 0; i < insertTuples.length; i++) {
  18683. this._perViewChange(insertTuples[i].view, insertTuples[i].record);
  18684. }
  18685. for (var i = 0, ilen = this._viewContainer.length; i < ilen; i++) {
  18686. this._viewContainer.get(i).setLocal('last', i === ilen - 1);
  18687. }
  18688. };
  18689. NgFor.prototype._perViewChange = function (view, record) {
  18690. view.setLocal('\$implicit', record.item);
  18691. view.setLocal('index', record.currentIndex);
  18692. view.setLocal('even', (record.currentIndex % 2 == 0));
  18693. view.setLocal('odd', (record.currentIndex % 2 == 1));
  18694. };
  18695. NgFor.prototype._bulkRemove = function (tuples) {
  18696. tuples.sort(function (a, b) { return a.record.previousIndex - b.record.previousIndex; });
  18697. var movedTuples = [];
  18698. for (var i = tuples.length - 1; i >= 0; i--) {
  18699. var tuple = tuples[i];
  18700. // separate moved views from removed views.
  18701. if (lang_1.isPresent(tuple.record.currentIndex)) {
  18702. tuple.view = this._viewContainer.detach(tuple.record.previousIndex);
  18703. movedTuples.push(tuple);
  18704. }
  18705. else {
  18706. this._viewContainer.remove(tuple.record.previousIndex);
  18707. }
  18708. }
  18709. return movedTuples;
  18710. };
  18711. NgFor.prototype._bulkInsert = function (tuples) {
  18712. tuples.sort(function (a, b) { return a.record.currentIndex - b.record.currentIndex; });
  18713. for (var i = 0; i < tuples.length; i++) {
  18714. var tuple = tuples[i];
  18715. if (lang_1.isPresent(tuple.view)) {
  18716. this._viewContainer.insert(tuple.view, tuple.record.currentIndex);
  18717. }
  18718. else {
  18719. tuple.view =
  18720. this._viewContainer.createEmbeddedView(this._templateRef, tuple.record.currentIndex);
  18721. }
  18722. }
  18723. return tuples;
  18724. };
  18725. NgFor = __decorate([
  18726. core_1.Directive({ selector: '[ngFor][ngForOf]', inputs: ['ngForOf', 'ngForTemplate'] }),
  18727. __metadata('design:paramtypes', [core_1.ViewContainerRef, core_1.TemplateRef, core_1.IterableDiffers, core_1.ChangeDetectorRef])
  18728. ], NgFor);
  18729. return NgFor;
  18730. })();
  18731. exports.NgFor = NgFor;
  18732. var RecordViewTuple = (function () {
  18733. function RecordViewTuple(record, view) {
  18734. this.record = record;
  18735. this.view = view;
  18736. }
  18737. return RecordViewTuple;
  18738. })();
  18739. /***/ },
  18740. /* 118 */
  18741. /***/ function(module, exports, __webpack_require__) {
  18742. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  18743. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  18744. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  18745. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  18746. return c > 3 && r && Object.defineProperty(target, key, r), r;
  18747. };
  18748. var __metadata = (this && this.__metadata) || function (k, v) {
  18749. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  18750. };
  18751. var core_1 = __webpack_require__(2);
  18752. var lang_1 = __webpack_require__(5);
  18753. /**
  18754. * Removes or recreates a portion of the DOM tree based on an {expression}.
  18755. *
  18756. * If the expression assigned to `ngIf` evaluates to a false value then the element
  18757. * is removed from the DOM, otherwise a clone of the element is reinserted into the DOM.
  18758. *
  18759. * ### Example ([live demo](http://plnkr.co/edit/fe0kgemFBtmQOY31b4tw?p=preview)):
  18760. *
  18761. * ```
  18762. * <div *ngIf="errorCount > 0" class="error">
  18763. * <!-- Error message displayed when the errorCount property on the current context is greater
  18764. * than 0. -->
  18765. * {{errorCount}} errors detected
  18766. * </div>
  18767. * ```
  18768. *
  18769. * ### Syntax
  18770. *
  18771. * - `<div *ngIf="condition">...</div>`
  18772. * - `<div template="ngIf condition">...</div>`
  18773. * - `<template [ngIf]="condition"><div>...</div></template>`
  18774. */
  18775. var NgIf = (function () {
  18776. function NgIf(_viewContainer, _templateRef) {
  18777. this._viewContainer = _viewContainer;
  18778. this._templateRef = _templateRef;
  18779. this._prevCondition = null;
  18780. }
  18781. Object.defineProperty(NgIf.prototype, "ngIf", {
  18782. set: function (newCondition /* boolean */) {
  18783. if (newCondition && (lang_1.isBlank(this._prevCondition) || !this._prevCondition)) {
  18784. this._prevCondition = true;
  18785. this._viewContainer.createEmbeddedView(this._templateRef);
  18786. }
  18787. else if (!newCondition && (lang_1.isBlank(this._prevCondition) || this._prevCondition)) {
  18788. this._prevCondition = false;
  18789. this._viewContainer.clear();
  18790. }
  18791. },
  18792. enumerable: true,
  18793. configurable: true
  18794. });
  18795. NgIf = __decorate([
  18796. core_1.Directive({ selector: '[ngIf]', inputs: ['ngIf'] }),
  18797. __metadata('design:paramtypes', [core_1.ViewContainerRef, core_1.TemplateRef])
  18798. ], NgIf);
  18799. return NgIf;
  18800. })();
  18801. exports.NgIf = NgIf;
  18802. /***/ },
  18803. /* 119 */
  18804. /***/ function(module, exports, __webpack_require__) {
  18805. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  18806. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  18807. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  18808. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  18809. return c > 3 && r && Object.defineProperty(target, key, r), r;
  18810. };
  18811. var __metadata = (this && this.__metadata) || function (k, v) {
  18812. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  18813. };
  18814. var core_1 = __webpack_require__(2);
  18815. var lang_1 = __webpack_require__(5);
  18816. /**
  18817. * The `NgStyle` directive changes styles based on a result of expression evaluation.
  18818. *
  18819. * An expression assigned to the `ngStyle` property must evaluate to an object and the
  18820. * corresponding element styles are updated based on changes to this object. Style names to update
  18821. * are taken from the object's keys, and values - from the corresponding object's values.
  18822. *
  18823. * ### Syntax
  18824. *
  18825. * - `<div [ngStyle]="{'font-style': style}"></div>`
  18826. * - `<div [ngStyle]="styleExp"></div>` - here the `styleExp` must evaluate to an object
  18827. *
  18828. * ### Example ([live demo](http://plnkr.co/edit/YamGS6GkUh9GqWNQhCyM?p=preview)):
  18829. *
  18830. * ```
  18831. * import {Component} from 'angular2/core';
  18832. * import {NgStyle} from 'angular2/common';
  18833. *
  18834. * @Component({
  18835. * selector: 'ngStyle-example',
  18836. * template: `
  18837. * <h1 [ngStyle]="{'font-style': style, 'font-size': size, 'font-weight': weight}">
  18838. * Change style of this text!
  18839. * </h1>
  18840. *
  18841. * <hr>
  18842. *
  18843. * <label>Italic: <input type="checkbox" (change)="changeStyle($event)"></label>
  18844. * <label>Bold: <input type="checkbox" (change)="changeWeight($event)"></label>
  18845. * <label>Size: <input type="text" [value]="size" (change)="size = $event.target.value"></label>
  18846. * `,
  18847. * directives: [NgStyle]
  18848. * })
  18849. * export class NgStyleExample {
  18850. * style = 'normal';
  18851. * weight = 'normal';
  18852. * size = '20px';
  18853. *
  18854. * changeStyle($event: any) {
  18855. * this.style = $event.target.checked ? 'italic' : 'normal';
  18856. * }
  18857. *
  18858. * changeWeight($event: any) {
  18859. * this.weight = $event.target.checked ? 'bold' : 'normal';
  18860. * }
  18861. * }
  18862. * ```
  18863. *
  18864. * In this example the `font-style`, `font-size` and `font-weight` styles will be updated
  18865. * based on the `style` property's value changes.
  18866. */
  18867. var NgStyle = (function () {
  18868. function NgStyle(_differs, _ngEl, _renderer) {
  18869. this._differs = _differs;
  18870. this._ngEl = _ngEl;
  18871. this._renderer = _renderer;
  18872. }
  18873. Object.defineProperty(NgStyle.prototype, "rawStyle", {
  18874. set: function (v) {
  18875. this._rawStyle = v;
  18876. if (lang_1.isBlank(this._differ) && lang_1.isPresent(v)) {
  18877. this._differ = this._differs.find(this._rawStyle).create(null);
  18878. }
  18879. },
  18880. enumerable: true,
  18881. configurable: true
  18882. });
  18883. NgStyle.prototype.ngDoCheck = function () {
  18884. if (lang_1.isPresent(this._differ)) {
  18885. var changes = this._differ.diff(this._rawStyle);
  18886. if (lang_1.isPresent(changes)) {
  18887. this._applyChanges(changes);
  18888. }
  18889. }
  18890. };
  18891. NgStyle.prototype._applyChanges = function (changes) {
  18892. var _this = this;
  18893. changes.forEachAddedItem(function (record) { _this._setStyle(record.key, record.currentValue); });
  18894. changes.forEachChangedItem(function (record) { _this._setStyle(record.key, record.currentValue); });
  18895. changes.forEachRemovedItem(function (record) { _this._setStyle(record.key, null); });
  18896. };
  18897. NgStyle.prototype._setStyle = function (name, val) {
  18898. this._renderer.setElementStyle(this._ngEl, name, val);
  18899. };
  18900. NgStyle = __decorate([
  18901. core_1.Directive({ selector: '[ngStyle]', inputs: ['rawStyle: ngStyle'] }),
  18902. __metadata('design:paramtypes', [core_1.KeyValueDiffers, core_1.ElementRef, core_1.Renderer])
  18903. ], NgStyle);
  18904. return NgStyle;
  18905. })();
  18906. exports.NgStyle = NgStyle;
  18907. /***/ },
  18908. /* 120 */
  18909. /***/ function(module, exports, __webpack_require__) {
  18910. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  18911. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  18912. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  18913. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  18914. return c > 3 && r && Object.defineProperty(target, key, r), r;
  18915. };
  18916. var __metadata = (this && this.__metadata) || function (k, v) {
  18917. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  18918. };
  18919. var __param = (this && this.__param) || function (paramIndex, decorator) {
  18920. return function (target, key) { decorator(target, key, paramIndex); }
  18921. };
  18922. var core_1 = __webpack_require__(2);
  18923. var lang_1 = __webpack_require__(5);
  18924. var collection_1 = __webpack_require__(12);
  18925. var _WHEN_DEFAULT = lang_1.CONST_EXPR(new Object());
  18926. var SwitchView = (function () {
  18927. function SwitchView(_viewContainerRef, _templateRef) {
  18928. this._viewContainerRef = _viewContainerRef;
  18929. this._templateRef = _templateRef;
  18930. }
  18931. SwitchView.prototype.create = function () { this._viewContainerRef.createEmbeddedView(this._templateRef); };
  18932. SwitchView.prototype.destroy = function () { this._viewContainerRef.clear(); };
  18933. return SwitchView;
  18934. })();
  18935. /**
  18936. * Adds or removes DOM sub-trees when their match expressions match the switch expression.
  18937. *
  18938. * Elements within `NgSwitch` but without `NgSwitchWhen` or `NgSwitchDefault` directives will be
  18939. * preserved at the location as specified in the template.
  18940. *
  18941. * `NgSwitch` simply inserts nested elements based on which match expression matches the value
  18942. * obtained from the evaluated switch expression. In other words, you define a container element
  18943. * (where you place the directive with a switch expression on the
  18944. * **`[ngSwitch]="..."` attribute**), define any inner elements inside of the directive and
  18945. * place a `[ngSwitchWhen]` attribute per element.
  18946. *
  18947. * The `ngSwitchWhen` property is used to inform `NgSwitch` which element to display when the
  18948. * expression is evaluated. If a matching expression is not found via a `ngSwitchWhen` property
  18949. * then an element with the `ngSwitchDefault` attribute is displayed.
  18950. *
  18951. * ### Example ([live demo](http://plnkr.co/edit/DQMTII95CbuqWrl3lYAs?p=preview))
  18952. *
  18953. * ```typescript
  18954. * @Component({selector: 'app'})
  18955. * @View({
  18956. * template: `
  18957. * <p>Value = {{value}}</p>
  18958. * <button (click)="inc()">Increment</button>
  18959. *
  18960. * <div [ngSwitch]="value">
  18961. * <p *ngSwitchWhen="'init'">increment to start</p>
  18962. * <p *ngSwitchWhen="0">0, increment again</p>
  18963. * <p *ngSwitchWhen="1">1, increment again</p>
  18964. * <p *ngSwitchWhen="2">2, stop incrementing</p>
  18965. * <p *ngSwitchDefault>&gt; 2, STOP!</p>
  18966. * </div>
  18967. *
  18968. * <!-- alternate syntax -->
  18969. *
  18970. * <p [ngSwitch]="value">
  18971. * <template ngSwitchWhen="init">increment to start</template>
  18972. * <template [ngSwitchWhen]="0">0, increment again</template>
  18973. * <template [ngSwitchWhen]="1">1, increment again</template>
  18974. * <template [ngSwitchWhen]="2">2, stop incrementing</template>
  18975. * <template ngSwitchDefault>&gt; 2, STOP!</template>
  18976. * </p>
  18977. * `,
  18978. * directives: [NgSwitch, NgSwitchWhen, NgSwitchDefault]
  18979. * })
  18980. * export class App {
  18981. * value = 'init';
  18982. *
  18983. * inc() {
  18984. * this.value = this.value === 'init' ? 0 : this.value + 1;
  18985. * }
  18986. * }
  18987. *
  18988. * bootstrap(App).catch(err => console.error(err));
  18989. * ```
  18990. */
  18991. var NgSwitch = (function () {
  18992. function NgSwitch() {
  18993. this._useDefault = false;
  18994. this._valueViews = new collection_1.Map();
  18995. this._activeViews = [];
  18996. }
  18997. Object.defineProperty(NgSwitch.prototype, "ngSwitch", {
  18998. set: function (value) {
  18999. // Empty the currently active ViewContainers
  19000. this._emptyAllActiveViews();
  19001. // Add the ViewContainers matching the value (with a fallback to default)
  19002. this._useDefault = false;
  19003. var views = this._valueViews.get(value);
  19004. if (lang_1.isBlank(views)) {
  19005. this._useDefault = true;
  19006. views = lang_1.normalizeBlank(this._valueViews.get(_WHEN_DEFAULT));
  19007. }
  19008. this._activateViews(views);
  19009. this._switchValue = value;
  19010. },
  19011. enumerable: true,
  19012. configurable: true
  19013. });
  19014. /** @internal */
  19015. NgSwitch.prototype._onWhenValueChanged = function (oldWhen, newWhen, view) {
  19016. this._deregisterView(oldWhen, view);
  19017. this._registerView(newWhen, view);
  19018. if (oldWhen === this._switchValue) {
  19019. view.destroy();
  19020. collection_1.ListWrapper.remove(this._activeViews, view);
  19021. }
  19022. else if (newWhen === this._switchValue) {
  19023. if (this._useDefault) {
  19024. this._useDefault = false;
  19025. this._emptyAllActiveViews();
  19026. }
  19027. view.create();
  19028. this._activeViews.push(view);
  19029. }
  19030. // Switch to default when there is no more active ViewContainers
  19031. if (this._activeViews.length === 0 && !this._useDefault) {
  19032. this._useDefault = true;
  19033. this._activateViews(this._valueViews.get(_WHEN_DEFAULT));
  19034. }
  19035. };
  19036. /** @internal */
  19037. NgSwitch.prototype._emptyAllActiveViews = function () {
  19038. var activeContainers = this._activeViews;
  19039. for (var i = 0; i < activeContainers.length; i++) {
  19040. activeContainers[i].destroy();
  19041. }
  19042. this._activeViews = [];
  19043. };
  19044. /** @internal */
  19045. NgSwitch.prototype._activateViews = function (views) {
  19046. // TODO(vicb): assert(this._activeViews.length === 0);
  19047. if (lang_1.isPresent(views)) {
  19048. for (var i = 0; i < views.length; i++) {
  19049. views[i].create();
  19050. }
  19051. this._activeViews = views;
  19052. }
  19053. };
  19054. /** @internal */
  19055. NgSwitch.prototype._registerView = function (value, view) {
  19056. var views = this._valueViews.get(value);
  19057. if (lang_1.isBlank(views)) {
  19058. views = [];
  19059. this._valueViews.set(value, views);
  19060. }
  19061. views.push(view);
  19062. };
  19063. /** @internal */
  19064. NgSwitch.prototype._deregisterView = function (value, view) {
  19065. // `_WHEN_DEFAULT` is used a marker for non-registered whens
  19066. if (value === _WHEN_DEFAULT)
  19067. return;
  19068. var views = this._valueViews.get(value);
  19069. if (views.length == 1) {
  19070. this._valueViews.delete(value);
  19071. }
  19072. else {
  19073. collection_1.ListWrapper.remove(views, view);
  19074. }
  19075. };
  19076. NgSwitch = __decorate([
  19077. core_1.Directive({ selector: '[ngSwitch]', inputs: ['ngSwitch'] }),
  19078. __metadata('design:paramtypes', [])
  19079. ], NgSwitch);
  19080. return NgSwitch;
  19081. })();
  19082. exports.NgSwitch = NgSwitch;
  19083. /**
  19084. * Insert the sub-tree when the `ngSwitchWhen` expression evaluates to the same value as the
  19085. * enclosing switch expression.
  19086. *
  19087. * If multiple match expression match the switch expression value, all of them are displayed.
  19088. *
  19089. * See {@link NgSwitch} for more details and example.
  19090. */
  19091. var NgSwitchWhen = (function () {
  19092. function NgSwitchWhen(viewContainer, templateRef, ngSwitch) {
  19093. // `_WHEN_DEFAULT` is used as a marker for a not yet initialized value
  19094. /** @internal */
  19095. this._value = _WHEN_DEFAULT;
  19096. this._switch = ngSwitch;
  19097. this._view = new SwitchView(viewContainer, templateRef);
  19098. }
  19099. Object.defineProperty(NgSwitchWhen.prototype, "ngSwitchWhen", {
  19100. set: function (value) {
  19101. this._switch._onWhenValueChanged(this._value, value, this._view);
  19102. this._value = value;
  19103. },
  19104. enumerable: true,
  19105. configurable: true
  19106. });
  19107. NgSwitchWhen = __decorate([
  19108. core_1.Directive({ selector: '[ngSwitchWhen]', inputs: ['ngSwitchWhen'] }),
  19109. __param(2, core_1.Host()),
  19110. __metadata('design:paramtypes', [core_1.ViewContainerRef, core_1.TemplateRef, NgSwitch])
  19111. ], NgSwitchWhen);
  19112. return NgSwitchWhen;
  19113. })();
  19114. exports.NgSwitchWhen = NgSwitchWhen;
  19115. /**
  19116. * Default case statements are displayed when no match expression matches the switch expression
  19117. * value.
  19118. *
  19119. * See {@link NgSwitch} for more details and example.
  19120. */
  19121. var NgSwitchDefault = (function () {
  19122. function NgSwitchDefault(viewContainer, templateRef, sswitch) {
  19123. sswitch._registerView(_WHEN_DEFAULT, new SwitchView(viewContainer, templateRef));
  19124. }
  19125. NgSwitchDefault = __decorate([
  19126. core_1.Directive({ selector: '[ngSwitchDefault]' }),
  19127. __param(2, core_1.Host()),
  19128. __metadata('design:paramtypes', [core_1.ViewContainerRef, core_1.TemplateRef, NgSwitch])
  19129. ], NgSwitchDefault);
  19130. return NgSwitchDefault;
  19131. })();
  19132. exports.NgSwitchDefault = NgSwitchDefault;
  19133. /***/ },
  19134. /* 121 */
  19135. /***/ function(module, exports) {
  19136. // TS does not have Observables
  19137. /***/ },
  19138. /* 122 */
  19139. /***/ function(module, exports, __webpack_require__) {
  19140. var lang_1 = __webpack_require__(5);
  19141. var ng_class_1 = __webpack_require__(116);
  19142. var ng_for_1 = __webpack_require__(117);
  19143. var ng_if_1 = __webpack_require__(118);
  19144. var ng_style_1 = __webpack_require__(119);
  19145. var ng_switch_1 = __webpack_require__(120);
  19146. /**
  19147. * A collection of Angular core directives that are likely to be used in each and every Angular
  19148. * application.
  19149. *
  19150. * This collection can be used to quickly enumerate all the built-in directives in the `directives`
  19151. * property of the `@View` annotation.
  19152. *
  19153. * ### Example ([live demo](http://plnkr.co/edit/yakGwpCdUkg0qfzX5m8g?p=preview))
  19154. *
  19155. * Instead of writing:
  19156. *
  19157. * ```typescript
  19158. * import {NgClass, NgIf, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/common';
  19159. * import {OtherDirective} from './myDirectives';
  19160. *
  19161. * @Component({
  19162. * selector: 'my-component',
  19163. * templateUrl: 'myComponent.html',
  19164. * directives: [NgClass, NgIf, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault, OtherDirective]
  19165. * })
  19166. * export class MyComponent {
  19167. * ...
  19168. * }
  19169. * ```
  19170. * one could import all the core directives at once:
  19171. *
  19172. * ```typescript
  19173. * import {CORE_DIRECTIVES} from 'angular2/common';
  19174. * import {OtherDirective} from './myDirectives';
  19175. *
  19176. * @Component({
  19177. * selector: 'my-component',
  19178. * templateUrl: 'myComponent.html',
  19179. * directives: [CORE_DIRECTIVES, OtherDirective]
  19180. * })
  19181. * export class MyComponent {
  19182. * ...
  19183. * }
  19184. * ```
  19185. */
  19186. exports.CORE_DIRECTIVES = lang_1.CONST_EXPR([ng_class_1.NgClass, ng_for_1.NgFor, ng_if_1.NgIf, ng_style_1.NgStyle, ng_switch_1.NgSwitch, ng_switch_1.NgSwitchWhen, ng_switch_1.NgSwitchDefault]);
  19187. /***/ },
  19188. /* 123 */
  19189. /***/ function(module, exports, __webpack_require__) {
  19190. /**
  19191. * @module
  19192. * @description
  19193. * This module is used for handling user input, by defining and building a {@link ControlGroup} that
  19194. * consists of
  19195. * {@link Control} objects, and mapping them onto the DOM. {@link Control} objects can then be used
  19196. * to read information
  19197. * from the form DOM elements.
  19198. *
  19199. * This module is not included in the `angular2` module; you must import the forms module
  19200. * explicitly.
  19201. *
  19202. */
  19203. var model_1 = __webpack_require__(124);
  19204. exports.AbstractControl = model_1.AbstractControl;
  19205. exports.Control = model_1.Control;
  19206. exports.ControlGroup = model_1.ControlGroup;
  19207. exports.ControlArray = model_1.ControlArray;
  19208. var abstract_control_directive_1 = __webpack_require__(125);
  19209. exports.AbstractControlDirective = abstract_control_directive_1.AbstractControlDirective;
  19210. var control_container_1 = __webpack_require__(126);
  19211. exports.ControlContainer = control_container_1.ControlContainer;
  19212. var ng_control_name_1 = __webpack_require__(127);
  19213. exports.NgControlName = ng_control_name_1.NgControlName;
  19214. var ng_form_control_1 = __webpack_require__(137);
  19215. exports.NgFormControl = ng_form_control_1.NgFormControl;
  19216. var ng_model_1 = __webpack_require__(138);
  19217. exports.NgModel = ng_model_1.NgModel;
  19218. var ng_control_1 = __webpack_require__(128);
  19219. exports.NgControl = ng_control_1.NgControl;
  19220. var ng_control_group_1 = __webpack_require__(139);
  19221. exports.NgControlGroup = ng_control_group_1.NgControlGroup;
  19222. var ng_form_model_1 = __webpack_require__(140);
  19223. exports.NgFormModel = ng_form_model_1.NgFormModel;
  19224. var ng_form_1 = __webpack_require__(141);
  19225. exports.NgForm = ng_form_1.NgForm;
  19226. var control_value_accessor_1 = __webpack_require__(129);
  19227. exports.NG_VALUE_ACCESSOR = control_value_accessor_1.NG_VALUE_ACCESSOR;
  19228. var default_value_accessor_1 = __webpack_require__(132);
  19229. exports.DefaultValueAccessor = default_value_accessor_1.DefaultValueAccessor;
  19230. var ng_control_status_1 = __webpack_require__(142);
  19231. exports.NgControlStatus = ng_control_status_1.NgControlStatus;
  19232. var checkbox_value_accessor_1 = __webpack_require__(134);
  19233. exports.CheckboxControlValueAccessor = checkbox_value_accessor_1.CheckboxControlValueAccessor;
  19234. var select_control_value_accessor_1 = __webpack_require__(135);
  19235. exports.NgSelectOption = select_control_value_accessor_1.NgSelectOption;
  19236. exports.SelectControlValueAccessor = select_control_value_accessor_1.SelectControlValueAccessor;
  19237. var directives_1 = __webpack_require__(143);
  19238. exports.FORM_DIRECTIVES = directives_1.FORM_DIRECTIVES;
  19239. var validators_1 = __webpack_require__(131);
  19240. exports.NG_VALIDATORS = validators_1.NG_VALIDATORS;
  19241. exports.NG_ASYNC_VALIDATORS = validators_1.NG_ASYNC_VALIDATORS;
  19242. exports.Validators = validators_1.Validators;
  19243. var validators_2 = __webpack_require__(144);
  19244. exports.RequiredValidator = validators_2.RequiredValidator;
  19245. exports.MinLengthValidator = validators_2.MinLengthValidator;
  19246. exports.MaxLengthValidator = validators_2.MaxLengthValidator;
  19247. var form_builder_1 = __webpack_require__(145);
  19248. exports.FormBuilder = form_builder_1.FormBuilder;
  19249. exports.FORM_PROVIDERS = form_builder_1.FORM_PROVIDERS;
  19250. exports.FORM_BINDINGS = form_builder_1.FORM_BINDINGS;
  19251. /***/ },
  19252. /* 124 */
  19253. /***/ function(module, exports, __webpack_require__) {
  19254. var __extends = (this && this.__extends) || function (d, b) {
  19255. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  19256. function __() { this.constructor = d; }
  19257. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  19258. };
  19259. var lang_1 = __webpack_require__(5);
  19260. var async_1 = __webpack_require__(60);
  19261. var promise_1 = __webpack_require__(61);
  19262. var collection_1 = __webpack_require__(12);
  19263. /**
  19264. * Indicates that a Control is valid, i.e. that no errors exist in the input value.
  19265. */
  19266. exports.VALID = "VALID";
  19267. /**
  19268. * Indicates that a Control is invalid, i.e. that an error exists in the input value.
  19269. */
  19270. exports.INVALID = "INVALID";
  19271. /**
  19272. * Indicates that a Control is pending, i.e. that async validation is occuring and
  19273. * errors are not yet available for the input value.
  19274. */
  19275. exports.PENDING = "PENDING";
  19276. function isControl(control) {
  19277. return control instanceof AbstractControl;
  19278. }
  19279. exports.isControl = isControl;
  19280. function _find(control, path) {
  19281. if (lang_1.isBlank(path))
  19282. return null;
  19283. if (!(path instanceof Array)) {
  19284. path = path.split("/");
  19285. }
  19286. if (path instanceof Array && collection_1.ListWrapper.isEmpty(path))
  19287. return null;
  19288. return path
  19289. .reduce(function (v, name) {
  19290. if (v instanceof ControlGroup) {
  19291. return lang_1.isPresent(v.controls[name]) ? v.controls[name] : null;
  19292. }
  19293. else if (v instanceof ControlArray) {
  19294. var index = name;
  19295. return lang_1.isPresent(v.at(index)) ? v.at(index) : null;
  19296. }
  19297. else {
  19298. return null;
  19299. }
  19300. }, control);
  19301. }
  19302. function toObservable(r) {
  19303. return promise_1.PromiseWrapper.isPromise(r) ? async_1.ObservableWrapper.fromPromise(r) : r;
  19304. }
  19305. /**
  19306. *
  19307. */
  19308. var AbstractControl = (function () {
  19309. function AbstractControl(validator, asyncValidator) {
  19310. this.validator = validator;
  19311. this.asyncValidator = asyncValidator;
  19312. this._pristine = true;
  19313. this._touched = false;
  19314. }
  19315. Object.defineProperty(AbstractControl.prototype, "value", {
  19316. get: function () { return this._value; },
  19317. enumerable: true,
  19318. configurable: true
  19319. });
  19320. Object.defineProperty(AbstractControl.prototype, "status", {
  19321. get: function () { return this._status; },
  19322. enumerable: true,
  19323. configurable: true
  19324. });
  19325. Object.defineProperty(AbstractControl.prototype, "valid", {
  19326. get: function () { return this._status === exports.VALID; },
  19327. enumerable: true,
  19328. configurable: true
  19329. });
  19330. Object.defineProperty(AbstractControl.prototype, "errors", {
  19331. /**
  19332. * Returns the errors of this control.
  19333. */
  19334. get: function () { return this._errors; },
  19335. enumerable: true,
  19336. configurable: true
  19337. });
  19338. Object.defineProperty(AbstractControl.prototype, "pristine", {
  19339. get: function () { return this._pristine; },
  19340. enumerable: true,
  19341. configurable: true
  19342. });
  19343. Object.defineProperty(AbstractControl.prototype, "dirty", {
  19344. get: function () { return !this.pristine; },
  19345. enumerable: true,
  19346. configurable: true
  19347. });
  19348. Object.defineProperty(AbstractControl.prototype, "touched", {
  19349. get: function () { return this._touched; },
  19350. enumerable: true,
  19351. configurable: true
  19352. });
  19353. Object.defineProperty(AbstractControl.prototype, "untouched", {
  19354. get: function () { return !this._touched; },
  19355. enumerable: true,
  19356. configurable: true
  19357. });
  19358. Object.defineProperty(AbstractControl.prototype, "valueChanges", {
  19359. get: function () { return this._valueChanges; },
  19360. enumerable: true,
  19361. configurable: true
  19362. });
  19363. Object.defineProperty(AbstractControl.prototype, "statusChanges", {
  19364. get: function () { return this._statusChanges; },
  19365. enumerable: true,
  19366. configurable: true
  19367. });
  19368. Object.defineProperty(AbstractControl.prototype, "pending", {
  19369. get: function () { return this._status == exports.PENDING; },
  19370. enumerable: true,
  19371. configurable: true
  19372. });
  19373. AbstractControl.prototype.markAsTouched = function () { this._touched = true; };
  19374. AbstractControl.prototype.markAsDirty = function (_a) {
  19375. var onlySelf = (_a === void 0 ? {} : _a).onlySelf;
  19376. onlySelf = lang_1.normalizeBool(onlySelf);
  19377. this._pristine = false;
  19378. if (lang_1.isPresent(this._parent) && !onlySelf) {
  19379. this._parent.markAsDirty({ onlySelf: onlySelf });
  19380. }
  19381. };
  19382. AbstractControl.prototype.markAsPending = function (_a) {
  19383. var onlySelf = (_a === void 0 ? {} : _a).onlySelf;
  19384. onlySelf = lang_1.normalizeBool(onlySelf);
  19385. this._status = exports.PENDING;
  19386. if (lang_1.isPresent(this._parent) && !onlySelf) {
  19387. this._parent.markAsPending({ onlySelf: onlySelf });
  19388. }
  19389. };
  19390. AbstractControl.prototype.setParent = function (parent) { this._parent = parent; };
  19391. AbstractControl.prototype.updateValueAndValidity = function (_a) {
  19392. var _b = _a === void 0 ? {} : _a, onlySelf = _b.onlySelf, emitEvent = _b.emitEvent;
  19393. onlySelf = lang_1.normalizeBool(onlySelf);
  19394. emitEvent = lang_1.isPresent(emitEvent) ? emitEvent : true;
  19395. this._updateValue();
  19396. this._errors = this._runValidator();
  19397. this._status = this._calculateStatus();
  19398. if (this._status == exports.VALID || this._status == exports.PENDING) {
  19399. this._runAsyncValidator(emitEvent);
  19400. }
  19401. if (emitEvent) {
  19402. async_1.ObservableWrapper.callEmit(this._valueChanges, this._value);
  19403. async_1.ObservableWrapper.callEmit(this._statusChanges, this._status);
  19404. }
  19405. if (lang_1.isPresent(this._parent) && !onlySelf) {
  19406. this._parent.updateValueAndValidity({ onlySelf: onlySelf, emitEvent: emitEvent });
  19407. }
  19408. };
  19409. AbstractControl.prototype._runValidator = function () { return lang_1.isPresent(this.validator) ? this.validator(this) : null; };
  19410. AbstractControl.prototype._runAsyncValidator = function (emitEvent) {
  19411. var _this = this;
  19412. if (lang_1.isPresent(this.asyncValidator)) {
  19413. this._status = exports.PENDING;
  19414. this._cancelExistingSubscription();
  19415. var obs = toObservable(this.asyncValidator(this));
  19416. this._asyncValidationSubscription =
  19417. async_1.ObservableWrapper.subscribe(obs, function (res) { return _this.setErrors(res, { emitEvent: emitEvent }); });
  19418. }
  19419. };
  19420. AbstractControl.prototype._cancelExistingSubscription = function () {
  19421. if (lang_1.isPresent(this._asyncValidationSubscription)) {
  19422. async_1.ObservableWrapper.dispose(this._asyncValidationSubscription);
  19423. }
  19424. };
  19425. /**
  19426. * Sets errors on a control.
  19427. *
  19428. * This is used when validations are run not automatically, but manually by the user.
  19429. *
  19430. * Calling `setErrors` will also update the validity of the parent control.
  19431. *
  19432. * ## Usage
  19433. *
  19434. * ```
  19435. * var login = new Control("someLogin");
  19436. * login.setErrors({
  19437. * "notUnique": true
  19438. * });
  19439. *
  19440. * expect(login.valid).toEqual(false);
  19441. * expect(login.errors).toEqual({"notUnique": true});
  19442. *
  19443. * login.updateValue("someOtherLogin");
  19444. *
  19445. * expect(login.valid).toEqual(true);
  19446. * ```
  19447. */
  19448. AbstractControl.prototype.setErrors = function (errors, _a) {
  19449. var emitEvent = (_a === void 0 ? {} : _a).emitEvent;
  19450. emitEvent = lang_1.isPresent(emitEvent) ? emitEvent : true;
  19451. this._errors = errors;
  19452. this._status = this._calculateStatus();
  19453. if (emitEvent) {
  19454. async_1.ObservableWrapper.callEmit(this._statusChanges, this._status);
  19455. }
  19456. if (lang_1.isPresent(this._parent)) {
  19457. this._parent._updateControlsErrors();
  19458. }
  19459. };
  19460. AbstractControl.prototype.find = function (path) { return _find(this, path); };
  19461. AbstractControl.prototype.getError = function (errorCode, path) {
  19462. if (path === void 0) { path = null; }
  19463. var control = lang_1.isPresent(path) && !collection_1.ListWrapper.isEmpty(path) ? this.find(path) : this;
  19464. if (lang_1.isPresent(control) && lang_1.isPresent(control._errors)) {
  19465. return collection_1.StringMapWrapper.get(control._errors, errorCode);
  19466. }
  19467. else {
  19468. return null;
  19469. }
  19470. };
  19471. AbstractControl.prototype.hasError = function (errorCode, path) {
  19472. if (path === void 0) { path = null; }
  19473. return lang_1.isPresent(this.getError(errorCode, path));
  19474. };
  19475. /** @internal */
  19476. AbstractControl.prototype._updateControlsErrors = function () {
  19477. this._status = this._calculateStatus();
  19478. if (lang_1.isPresent(this._parent)) {
  19479. this._parent._updateControlsErrors();
  19480. }
  19481. };
  19482. /** @internal */
  19483. AbstractControl.prototype._initObservables = function () {
  19484. this._valueChanges = new async_1.EventEmitter();
  19485. this._statusChanges = new async_1.EventEmitter();
  19486. };
  19487. AbstractControl.prototype._calculateStatus = function () {
  19488. if (lang_1.isPresent(this._errors))
  19489. return exports.INVALID;
  19490. if (this._anyControlsHaveStatus(exports.PENDING))
  19491. return exports.PENDING;
  19492. if (this._anyControlsHaveStatus(exports.INVALID))
  19493. return exports.INVALID;
  19494. return exports.VALID;
  19495. };
  19496. return AbstractControl;
  19497. })();
  19498. exports.AbstractControl = AbstractControl;
  19499. /**
  19500. * Defines a part of a form that cannot be divided into other controls. `Control`s have values and
  19501. * validation state, which is determined by an optional validation function.
  19502. *
  19503. * `Control` is one of the three fundamental building blocks used to define forms in Angular, along
  19504. * with {@link ControlGroup} and {@link ControlArray}.
  19505. *
  19506. * ## Usage
  19507. *
  19508. * By default, a `Control` is created for every `<input>` or other form component.
  19509. * With {@link NgFormControl} or {@link NgFormModel} an existing {@link Control} can be
  19510. * bound to a DOM element instead. This `Control` can be configured with a custom
  19511. * validation function.
  19512. *
  19513. * ### Example ([live demo](http://plnkr.co/edit/23DESOpbNnBpBHZt1BR4?p=preview))
  19514. */
  19515. var Control = (function (_super) {
  19516. __extends(Control, _super);
  19517. function Control(value, validator, asyncValidator) {
  19518. if (value === void 0) { value = null; }
  19519. if (validator === void 0) { validator = null; }
  19520. if (asyncValidator === void 0) { asyncValidator = null; }
  19521. _super.call(this, validator, asyncValidator);
  19522. this._value = value;
  19523. this.updateValueAndValidity({ onlySelf: true, emitEvent: false });
  19524. this._initObservables();
  19525. }
  19526. /**
  19527. * Set the value of the control to `value`.
  19528. *
  19529. * If `onlySelf` is `true`, this change will only affect the validation of this `Control`
  19530. * and not its parent component. If `emitEvent` is `true`, this change will cause a
  19531. * `valueChanges` event on the `Control` to be emitted. Both of these options default to
  19532. * `false`.
  19533. *
  19534. * If `emitModelToViewChange` is `true`, the view will be notified about the new value
  19535. * via an `onChange` event. This is the default behavior if `emitModelToViewChange` is not
  19536. * specified.
  19537. */
  19538. Control.prototype.updateValue = function (value, _a) {
  19539. var _b = _a === void 0 ? {} : _a, onlySelf = _b.onlySelf, emitEvent = _b.emitEvent, emitModelToViewChange = _b.emitModelToViewChange;
  19540. emitModelToViewChange = lang_1.isPresent(emitModelToViewChange) ? emitModelToViewChange : true;
  19541. this._value = value;
  19542. if (lang_1.isPresent(this._onChange) && emitModelToViewChange)
  19543. this._onChange(this._value);
  19544. this.updateValueAndValidity({ onlySelf: onlySelf, emitEvent: emitEvent });
  19545. };
  19546. /**
  19547. * @internal
  19548. */
  19549. Control.prototype._updateValue = function () { };
  19550. /**
  19551. * @internal
  19552. */
  19553. Control.prototype._anyControlsHaveStatus = function (status) { return false; };
  19554. /**
  19555. * Register a listener for change events.
  19556. */
  19557. Control.prototype.registerOnChange = function (fn) { this._onChange = fn; };
  19558. return Control;
  19559. })(AbstractControl);
  19560. exports.Control = Control;
  19561. /**
  19562. * Defines a part of a form, of fixed length, that can contain other controls.
  19563. *
  19564. * A `ControlGroup` aggregates the values and errors of each {@link Control} in the group. Thus, if
  19565. * one of the controls in a group is invalid, the entire group is invalid. Similarly, if a control
  19566. * changes its value, the entire group changes as well.
  19567. *
  19568. * `ControlGroup` is one of the three fundamental building blocks used to define forms in Angular,
  19569. * along with {@link Control} and {@link ControlArray}. {@link ControlArray} can also contain other
  19570. * controls, but is of variable length.
  19571. *
  19572. * ### Example ([live demo](http://plnkr.co/edit/23DESOpbNnBpBHZt1BR4?p=preview))
  19573. */
  19574. var ControlGroup = (function (_super) {
  19575. __extends(ControlGroup, _super);
  19576. function ControlGroup(controls, optionals, validator, asyncValidator) {
  19577. if (optionals === void 0) { optionals = null; }
  19578. if (validator === void 0) { validator = null; }
  19579. if (asyncValidator === void 0) { asyncValidator = null; }
  19580. _super.call(this, validator, asyncValidator);
  19581. this.controls = controls;
  19582. this._optionals = lang_1.isPresent(optionals) ? optionals : {};
  19583. this._initObservables();
  19584. this._setParentForControls();
  19585. this.updateValueAndValidity({ onlySelf: true, emitEvent: false });
  19586. }
  19587. /**
  19588. * Add a control to this group.
  19589. */
  19590. ControlGroup.prototype.addControl = function (name, control) {
  19591. this.controls[name] = control;
  19592. control.setParent(this);
  19593. };
  19594. /**
  19595. * Remove a control from this group.
  19596. */
  19597. ControlGroup.prototype.removeControl = function (name) { collection_1.StringMapWrapper.delete(this.controls, name); };
  19598. /**
  19599. * Mark the named control as non-optional.
  19600. */
  19601. ControlGroup.prototype.include = function (controlName) {
  19602. collection_1.StringMapWrapper.set(this._optionals, controlName, true);
  19603. this.updateValueAndValidity();
  19604. };
  19605. /**
  19606. * Mark the named control as optional.
  19607. */
  19608. ControlGroup.prototype.exclude = function (controlName) {
  19609. collection_1.StringMapWrapper.set(this._optionals, controlName, false);
  19610. this.updateValueAndValidity();
  19611. };
  19612. /**
  19613. * Check whether there is a control with the given name in the group.
  19614. */
  19615. ControlGroup.prototype.contains = function (controlName) {
  19616. var c = collection_1.StringMapWrapper.contains(this.controls, controlName);
  19617. return c && this._included(controlName);
  19618. };
  19619. /** @internal */
  19620. ControlGroup.prototype._setParentForControls = function () {
  19621. var _this = this;
  19622. collection_1.StringMapWrapper.forEach(this.controls, function (control, name) { control.setParent(_this); });
  19623. };
  19624. /** @internal */
  19625. ControlGroup.prototype._updateValue = function () { this._value = this._reduceValue(); };
  19626. /** @internal */
  19627. ControlGroup.prototype._anyControlsHaveStatus = function (status) {
  19628. var _this = this;
  19629. var res = false;
  19630. collection_1.StringMapWrapper.forEach(this.controls, function (control, name) {
  19631. res = res || (_this.contains(name) && control.status == status);
  19632. });
  19633. return res;
  19634. };
  19635. /** @internal */
  19636. ControlGroup.prototype._reduceValue = function () {
  19637. return this._reduceChildren({}, function (acc, control, name) {
  19638. acc[name] = control.value;
  19639. return acc;
  19640. });
  19641. };
  19642. /** @internal */
  19643. ControlGroup.prototype._reduceChildren = function (initValue, fn) {
  19644. var _this = this;
  19645. var res = initValue;
  19646. collection_1.StringMapWrapper.forEach(this.controls, function (control, name) {
  19647. if (_this._included(name)) {
  19648. res = fn(res, control, name);
  19649. }
  19650. });
  19651. return res;
  19652. };
  19653. /** @internal */
  19654. ControlGroup.prototype._included = function (controlName) {
  19655. var isOptional = collection_1.StringMapWrapper.contains(this._optionals, controlName);
  19656. return !isOptional || collection_1.StringMapWrapper.get(this._optionals, controlName);
  19657. };
  19658. return ControlGroup;
  19659. })(AbstractControl);
  19660. exports.ControlGroup = ControlGroup;
  19661. /**
  19662. * Defines a part of a form, of variable length, that can contain other controls.
  19663. *
  19664. * A `ControlArray` aggregates the values and errors of each {@link Control} in the group. Thus, if
  19665. * one of the controls in a group is invalid, the entire group is invalid. Similarly, if a control
  19666. * changes its value, the entire group changes as well.
  19667. *
  19668. * `ControlArray` is one of the three fundamental building blocks used to define forms in Angular,
  19669. * along with {@link Control} and {@link ControlGroup}. {@link ControlGroup} can also contain
  19670. * other controls, but is of fixed length.
  19671. *
  19672. * ## Adding or removing controls
  19673. *
  19674. * To change the controls in the array, use the `push`, `insert`, or `removeAt` methods
  19675. * in `ControlArray` itself. These methods ensure the controls are properly tracked in the
  19676. * form's hierarchy. Do not modify the array of `AbstractControl`s used to instantiate
  19677. * the `ControlArray` directly, as that will result in strange and unexpected behavior such
  19678. * as broken change detection.
  19679. *
  19680. * ### Example ([live demo](http://plnkr.co/edit/23DESOpbNnBpBHZt1BR4?p=preview))
  19681. */
  19682. var ControlArray = (function (_super) {
  19683. __extends(ControlArray, _super);
  19684. function ControlArray(controls, validator, asyncValidator) {
  19685. if (validator === void 0) { validator = null; }
  19686. if (asyncValidator === void 0) { asyncValidator = null; }
  19687. _super.call(this, validator, asyncValidator);
  19688. this.controls = controls;
  19689. this._initObservables();
  19690. this._setParentForControls();
  19691. this.updateValueAndValidity({ onlySelf: true, emitEvent: false });
  19692. }
  19693. /**
  19694. * Get the {@link AbstractControl} at the given `index` in the array.
  19695. */
  19696. ControlArray.prototype.at = function (index) { return this.controls[index]; };
  19697. /**
  19698. * Insert a new {@link AbstractControl} at the end of the array.
  19699. */
  19700. ControlArray.prototype.push = function (control) {
  19701. this.controls.push(control);
  19702. control.setParent(this);
  19703. this.updateValueAndValidity();
  19704. };
  19705. /**
  19706. * Insert a new {@link AbstractControl} at the given `index` in the array.
  19707. */
  19708. ControlArray.prototype.insert = function (index, control) {
  19709. collection_1.ListWrapper.insert(this.controls, index, control);
  19710. control.setParent(this);
  19711. this.updateValueAndValidity();
  19712. };
  19713. /**
  19714. * Remove the control at the given `index` in the array.
  19715. */
  19716. ControlArray.prototype.removeAt = function (index) {
  19717. collection_1.ListWrapper.removeAt(this.controls, index);
  19718. this.updateValueAndValidity();
  19719. };
  19720. Object.defineProperty(ControlArray.prototype, "length", {
  19721. /**
  19722. * Length of the control array.
  19723. */
  19724. get: function () { return this.controls.length; },
  19725. enumerable: true,
  19726. configurable: true
  19727. });
  19728. /** @internal */
  19729. ControlArray.prototype._updateValue = function () { this._value = this.controls.map(function (control) { return control.value; }); };
  19730. /** @internal */
  19731. ControlArray.prototype._anyControlsHaveStatus = function (status) {
  19732. return this.controls.some(function (c) { return c.status == status; });
  19733. };
  19734. /** @internal */
  19735. ControlArray.prototype._setParentForControls = function () {
  19736. var _this = this;
  19737. this.controls.forEach(function (control) { control.setParent(_this); });
  19738. };
  19739. return ControlArray;
  19740. })(AbstractControl);
  19741. exports.ControlArray = ControlArray;
  19742. /***/ },
  19743. /* 125 */
  19744. /***/ function(module, exports, __webpack_require__) {
  19745. var lang_1 = __webpack_require__(5);
  19746. var exceptions_1 = __webpack_require__(14);
  19747. /**
  19748. * Base class for control directives.
  19749. *
  19750. * Only used internally in the forms module.
  19751. */
  19752. var AbstractControlDirective = (function () {
  19753. function AbstractControlDirective() {
  19754. }
  19755. Object.defineProperty(AbstractControlDirective.prototype, "control", {
  19756. get: function () { return exceptions_1.unimplemented(); },
  19757. enumerable: true,
  19758. configurable: true
  19759. });
  19760. Object.defineProperty(AbstractControlDirective.prototype, "value", {
  19761. get: function () { return lang_1.isPresent(this.control) ? this.control.value : null; },
  19762. enumerable: true,
  19763. configurable: true
  19764. });
  19765. Object.defineProperty(AbstractControlDirective.prototype, "valid", {
  19766. get: function () { return lang_1.isPresent(this.control) ? this.control.valid : null; },
  19767. enumerable: true,
  19768. configurable: true
  19769. });
  19770. Object.defineProperty(AbstractControlDirective.prototype, "errors", {
  19771. get: function () {
  19772. return lang_1.isPresent(this.control) ? this.control.errors : null;
  19773. },
  19774. enumerable: true,
  19775. configurable: true
  19776. });
  19777. Object.defineProperty(AbstractControlDirective.prototype, "pristine", {
  19778. get: function () { return lang_1.isPresent(this.control) ? this.control.pristine : null; },
  19779. enumerable: true,
  19780. configurable: true
  19781. });
  19782. Object.defineProperty(AbstractControlDirective.prototype, "dirty", {
  19783. get: function () { return lang_1.isPresent(this.control) ? this.control.dirty : null; },
  19784. enumerable: true,
  19785. configurable: true
  19786. });
  19787. Object.defineProperty(AbstractControlDirective.prototype, "touched", {
  19788. get: function () { return lang_1.isPresent(this.control) ? this.control.touched : null; },
  19789. enumerable: true,
  19790. configurable: true
  19791. });
  19792. Object.defineProperty(AbstractControlDirective.prototype, "untouched", {
  19793. get: function () { return lang_1.isPresent(this.control) ? this.control.untouched : null; },
  19794. enumerable: true,
  19795. configurable: true
  19796. });
  19797. Object.defineProperty(AbstractControlDirective.prototype, "path", {
  19798. get: function () { return null; },
  19799. enumerable: true,
  19800. configurable: true
  19801. });
  19802. return AbstractControlDirective;
  19803. })();
  19804. exports.AbstractControlDirective = AbstractControlDirective;
  19805. /***/ },
  19806. /* 126 */
  19807. /***/ function(module, exports, __webpack_require__) {
  19808. var __extends = (this && this.__extends) || function (d, b) {
  19809. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  19810. function __() { this.constructor = d; }
  19811. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  19812. };
  19813. var abstract_control_directive_1 = __webpack_require__(125);
  19814. /**
  19815. * A directive that contains multiple {@link NgControl}s.
  19816. *
  19817. * Only used by the forms module.
  19818. */
  19819. var ControlContainer = (function (_super) {
  19820. __extends(ControlContainer, _super);
  19821. function ControlContainer() {
  19822. _super.apply(this, arguments);
  19823. }
  19824. Object.defineProperty(ControlContainer.prototype, "formDirective", {
  19825. /**
  19826. * Get the form to which this container belongs.
  19827. */
  19828. get: function () { return null; },
  19829. enumerable: true,
  19830. configurable: true
  19831. });
  19832. Object.defineProperty(ControlContainer.prototype, "path", {
  19833. /**
  19834. * Get the path to this container.
  19835. */
  19836. get: function () { return null; },
  19837. enumerable: true,
  19838. configurable: true
  19839. });
  19840. return ControlContainer;
  19841. })(abstract_control_directive_1.AbstractControlDirective);
  19842. exports.ControlContainer = ControlContainer;
  19843. /***/ },
  19844. /* 127 */
  19845. /***/ function(module, exports, __webpack_require__) {
  19846. var __extends = (this && this.__extends) || function (d, b) {
  19847. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  19848. function __() { this.constructor = d; }
  19849. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  19850. };
  19851. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19852. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  19853. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  19854. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  19855. return c > 3 && r && Object.defineProperty(target, key, r), r;
  19856. };
  19857. var __metadata = (this && this.__metadata) || function (k, v) {
  19858. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  19859. };
  19860. var __param = (this && this.__param) || function (paramIndex, decorator) {
  19861. return function (target, key) { decorator(target, key, paramIndex); }
  19862. };
  19863. var lang_1 = __webpack_require__(5);
  19864. var async_1 = __webpack_require__(60);
  19865. var core_1 = __webpack_require__(2);
  19866. var control_container_1 = __webpack_require__(126);
  19867. var ng_control_1 = __webpack_require__(128);
  19868. var control_value_accessor_1 = __webpack_require__(129);
  19869. var shared_1 = __webpack_require__(130);
  19870. var validators_1 = __webpack_require__(131);
  19871. var controlNameBinding = lang_1.CONST_EXPR(new core_1.Provider(ng_control_1.NgControl, { useExisting: core_1.forwardRef(function () { return NgControlName; }) }));
  19872. /**
  19873. * Creates and binds a control with a specified name to a DOM element.
  19874. *
  19875. * This directive can only be used as a child of {@link NgForm} or {@link NgFormModel}.
  19876. * ### Example
  19877. *
  19878. * In this example, we create the login and password controls.
  19879. * We can work with each control separately: check its validity, get its value, listen to its
  19880. * changes.
  19881. *
  19882. * ```
  19883. * @Component({
  19884. * selector: "login-comp",
  19885. * directives: [FORM_DIRECTIVES],
  19886. * template: `
  19887. * <form #f="ngForm" (submit)='onLogIn(f.value)'>
  19888. * Login <input type='text' ngControl='login' #l="form">
  19889. * <div *ngIf="!l.valid">Login is invalid</div>
  19890. *
  19891. * Password <input type='password' ngControl='password'>
  19892. * <button type='submit'>Log in!</button>
  19893. * </form>
  19894. * `})
  19895. * class LoginComp {
  19896. * onLogIn(value): void {
  19897. * // value === {login: 'some login', password: 'some password'}
  19898. * }
  19899. * }
  19900. * ```
  19901. *
  19902. * We can also use ngModel to bind a domain model to the form.
  19903. *
  19904. * ```
  19905. * @Component({
  19906. * selector: "login-comp",
  19907. * directives: [FORM_DIRECTIVES],
  19908. * template: `
  19909. * <form (submit)='onLogIn()'>
  19910. * Login <input type='text' ngControl='login' [(ngModel)]="credentials.login">
  19911. * Password <input type='password' ngControl='password'
  19912. * [(ngModel)]="credentials.password">
  19913. * <button type='submit'>Log in!</button>
  19914. * </form>
  19915. * `})
  19916. * class LoginComp {
  19917. * credentials: {login:string, password:string};
  19918. *
  19919. * onLogIn(): void {
  19920. * // this.credentials.login === "some login"
  19921. * // this.credentials.password === "some password"
  19922. * }
  19923. * }
  19924. * ```
  19925. */
  19926. var NgControlName = (function (_super) {
  19927. __extends(NgControlName, _super);
  19928. function NgControlName(_parent, _validators, _asyncValidators, valueAccessors) {
  19929. _super.call(this);
  19930. this._parent = _parent;
  19931. this._validators = _validators;
  19932. this._asyncValidators = _asyncValidators;
  19933. /** @internal */
  19934. this.update = new async_1.EventEmitter();
  19935. this._added = false;
  19936. this.valueAccessor = shared_1.selectValueAccessor(this, valueAccessors);
  19937. }
  19938. NgControlName.prototype.ngOnChanges = function (changes) {
  19939. if (!this._added) {
  19940. this.formDirective.addControl(this);
  19941. this._added = true;
  19942. }
  19943. if (shared_1.isPropertyUpdated(changes, this.viewModel)) {
  19944. this.viewModel = this.model;
  19945. this.formDirective.updateModel(this, this.model);
  19946. }
  19947. };
  19948. NgControlName.prototype.ngOnDestroy = function () { this.formDirective.removeControl(this); };
  19949. NgControlName.prototype.viewToModelUpdate = function (newValue) {
  19950. this.viewModel = newValue;
  19951. async_1.ObservableWrapper.callEmit(this.update, newValue);
  19952. };
  19953. Object.defineProperty(NgControlName.prototype, "path", {
  19954. get: function () { return shared_1.controlPath(this.name, this._parent); },
  19955. enumerable: true,
  19956. configurable: true
  19957. });
  19958. Object.defineProperty(NgControlName.prototype, "formDirective", {
  19959. get: function () { return this._parent.formDirective; },
  19960. enumerable: true,
  19961. configurable: true
  19962. });
  19963. Object.defineProperty(NgControlName.prototype, "validator", {
  19964. get: function () { return shared_1.composeValidators(this._validators); },
  19965. enumerable: true,
  19966. configurable: true
  19967. });
  19968. Object.defineProperty(NgControlName.prototype, "asyncValidator", {
  19969. get: function () { return shared_1.composeAsyncValidators(this._asyncValidators); },
  19970. enumerable: true,
  19971. configurable: true
  19972. });
  19973. Object.defineProperty(NgControlName.prototype, "control", {
  19974. get: function () { return this.formDirective.getControl(this); },
  19975. enumerable: true,
  19976. configurable: true
  19977. });
  19978. NgControlName = __decorate([
  19979. core_1.Directive({
  19980. selector: '[ngControl]',
  19981. bindings: [controlNameBinding],
  19982. inputs: ['name: ngControl', 'model: ngModel'],
  19983. outputs: ['update: ngModelChange'],
  19984. exportAs: 'ngForm'
  19985. }),
  19986. __param(0, core_1.Host()),
  19987. __param(0, core_1.SkipSelf()),
  19988. __param(1, core_1.Optional()),
  19989. __param(1, core_1.Self()),
  19990. __param(1, core_1.Inject(validators_1.NG_VALIDATORS)),
  19991. __param(2, core_1.Optional()),
  19992. __param(2, core_1.Self()),
  19993. __param(2, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)),
  19994. __param(3, core_1.Optional()),
  19995. __param(3, core_1.Self()),
  19996. __param(3, core_1.Inject(control_value_accessor_1.NG_VALUE_ACCESSOR)),
  19997. __metadata('design:paramtypes', [control_container_1.ControlContainer, Array, Array, Array])
  19998. ], NgControlName);
  19999. return NgControlName;
  20000. })(ng_control_1.NgControl);
  20001. exports.NgControlName = NgControlName;
  20002. /***/ },
  20003. /* 128 */
  20004. /***/ function(module, exports, __webpack_require__) {
  20005. var __extends = (this && this.__extends) || function (d, b) {
  20006. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  20007. function __() { this.constructor = d; }
  20008. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20009. };
  20010. var abstract_control_directive_1 = __webpack_require__(125);
  20011. var exceptions_1 = __webpack_require__(14);
  20012. /**
  20013. * A base class that all control directive extend.
  20014. * It binds a {@link Control} object to a DOM element.
  20015. *
  20016. * Used internally by Angular forms.
  20017. */
  20018. var NgControl = (function (_super) {
  20019. __extends(NgControl, _super);
  20020. function NgControl() {
  20021. _super.apply(this, arguments);
  20022. this.name = null;
  20023. this.valueAccessor = null;
  20024. }
  20025. Object.defineProperty(NgControl.prototype, "validator", {
  20026. get: function () { return exceptions_1.unimplemented(); },
  20027. enumerable: true,
  20028. configurable: true
  20029. });
  20030. Object.defineProperty(NgControl.prototype, "asyncValidator", {
  20031. get: function () { return exceptions_1.unimplemented(); },
  20032. enumerable: true,
  20033. configurable: true
  20034. });
  20035. return NgControl;
  20036. })(abstract_control_directive_1.AbstractControlDirective);
  20037. exports.NgControl = NgControl;
  20038. /***/ },
  20039. /* 129 */
  20040. /***/ function(module, exports, __webpack_require__) {
  20041. var core_1 = __webpack_require__(2);
  20042. var lang_1 = __webpack_require__(5);
  20043. /**
  20044. * Used to provide a {@link ControlValueAccessor} for form controls.
  20045. *
  20046. * See {@link DefaultValueAccessor} for how to implement one.
  20047. */
  20048. exports.NG_VALUE_ACCESSOR = lang_1.CONST_EXPR(new core_1.OpaqueToken("NgValueAccessor"));
  20049. /***/ },
  20050. /* 130 */
  20051. /***/ function(module, exports, __webpack_require__) {
  20052. var collection_1 = __webpack_require__(12);
  20053. var lang_1 = __webpack_require__(5);
  20054. var exceptions_1 = __webpack_require__(14);
  20055. var validators_1 = __webpack_require__(131);
  20056. var default_value_accessor_1 = __webpack_require__(132);
  20057. var number_value_accessor_1 = __webpack_require__(133);
  20058. var checkbox_value_accessor_1 = __webpack_require__(134);
  20059. var select_control_value_accessor_1 = __webpack_require__(135);
  20060. var normalize_validator_1 = __webpack_require__(136);
  20061. function controlPath(name, parent) {
  20062. var p = collection_1.ListWrapper.clone(parent.path);
  20063. p.push(name);
  20064. return p;
  20065. }
  20066. exports.controlPath = controlPath;
  20067. function setUpControl(control, dir) {
  20068. if (lang_1.isBlank(control))
  20069. _throwError(dir, "Cannot find control");
  20070. if (lang_1.isBlank(dir.valueAccessor))
  20071. _throwError(dir, "No value accessor for");
  20072. control.validator = validators_1.Validators.compose([control.validator, dir.validator]);
  20073. control.asyncValidator = validators_1.Validators.composeAsync([control.asyncValidator, dir.asyncValidator]);
  20074. dir.valueAccessor.writeValue(control.value);
  20075. // view -> model
  20076. dir.valueAccessor.registerOnChange(function (newValue) {
  20077. dir.viewToModelUpdate(newValue);
  20078. control.updateValue(newValue, { emitModelToViewChange: false });
  20079. control.markAsDirty();
  20080. });
  20081. // model -> view
  20082. control.registerOnChange(function (newValue) { return dir.valueAccessor.writeValue(newValue); });
  20083. // touched
  20084. dir.valueAccessor.registerOnTouched(function () { return control.markAsTouched(); });
  20085. }
  20086. exports.setUpControl = setUpControl;
  20087. function setUpControlGroup(control, dir) {
  20088. if (lang_1.isBlank(control))
  20089. _throwError(dir, "Cannot find control");
  20090. control.validator = validators_1.Validators.compose([control.validator, dir.validator]);
  20091. control.asyncValidator = validators_1.Validators.composeAsync([control.asyncValidator, dir.asyncValidator]);
  20092. }
  20093. exports.setUpControlGroup = setUpControlGroup;
  20094. function _throwError(dir, message) {
  20095. var path = dir.path.join(" -> ");
  20096. throw new exceptions_1.BaseException(message + " '" + path + "'");
  20097. }
  20098. function composeValidators(validators) {
  20099. return lang_1.isPresent(validators) ? validators_1.Validators.compose(validators.map(normalize_validator_1.normalizeValidator)) : null;
  20100. }
  20101. exports.composeValidators = composeValidators;
  20102. function composeAsyncValidators(validators) {
  20103. return lang_1.isPresent(validators) ? validators_1.Validators.composeAsync(validators.map(normalize_validator_1.normalizeValidator)) : null;
  20104. }
  20105. exports.composeAsyncValidators = composeAsyncValidators;
  20106. function isPropertyUpdated(changes, viewModel) {
  20107. if (!collection_1.StringMapWrapper.contains(changes, "model"))
  20108. return false;
  20109. var change = changes["model"];
  20110. if (change.isFirstChange())
  20111. return true;
  20112. return !lang_1.looseIdentical(viewModel, change.currentValue);
  20113. }
  20114. exports.isPropertyUpdated = isPropertyUpdated;
  20115. // TODO: vsavkin remove it once https://github.com/angular/angular/issues/3011 is implemented
  20116. function selectValueAccessor(dir, valueAccessors) {
  20117. if (lang_1.isBlank(valueAccessors))
  20118. return null;
  20119. var defaultAccessor;
  20120. var builtinAccessor;
  20121. var customAccessor;
  20122. valueAccessors.forEach(function (v) {
  20123. if (v instanceof default_value_accessor_1.DefaultValueAccessor) {
  20124. defaultAccessor = v;
  20125. }
  20126. else if (v instanceof checkbox_value_accessor_1.CheckboxControlValueAccessor || v instanceof number_value_accessor_1.NumberValueAccessor ||
  20127. v instanceof select_control_value_accessor_1.SelectControlValueAccessor) {
  20128. if (lang_1.isPresent(builtinAccessor))
  20129. _throwError(dir, "More than one built-in value accessor matches");
  20130. builtinAccessor = v;
  20131. }
  20132. else {
  20133. if (lang_1.isPresent(customAccessor))
  20134. _throwError(dir, "More than one custom value accessor matches");
  20135. customAccessor = v;
  20136. }
  20137. });
  20138. if (lang_1.isPresent(customAccessor))
  20139. return customAccessor;
  20140. if (lang_1.isPresent(builtinAccessor))
  20141. return builtinAccessor;
  20142. if (lang_1.isPresent(defaultAccessor))
  20143. return defaultAccessor;
  20144. _throwError(dir, "No valid value accessor for");
  20145. return null;
  20146. }
  20147. exports.selectValueAccessor = selectValueAccessor;
  20148. /***/ },
  20149. /* 131 */
  20150. /***/ function(module, exports, __webpack_require__) {
  20151. var lang_1 = __webpack_require__(5);
  20152. var promise_1 = __webpack_require__(61);
  20153. var async_1 = __webpack_require__(60);
  20154. var collection_1 = __webpack_require__(12);
  20155. var core_1 = __webpack_require__(2);
  20156. /**
  20157. * Providers for validators to be used for {@link Control}s in a form.
  20158. *
  20159. * Provide this using `multi: true` to add validators.
  20160. *
  20161. * ### Example
  20162. *
  20163. * {@example core/forms/ts/ng_validators/ng_validators.ts region='ng_validators'}
  20164. */
  20165. exports.NG_VALIDATORS = lang_1.CONST_EXPR(new core_1.OpaqueToken("NgValidators"));
  20166. /**
  20167. * Providers for asynchronous validators to be used for {@link Control}s
  20168. * in a form.
  20169. *
  20170. * Provide this using `multi: true` to add validators.
  20171. *
  20172. * See {@link NG_VALIDATORS} for more details.
  20173. */
  20174. exports.NG_ASYNC_VALIDATORS = lang_1.CONST_EXPR(new core_1.OpaqueToken("NgAsyncValidators"));
  20175. /**
  20176. * Provides a set of validators used by form controls.
  20177. *
  20178. * A validator is a function that processes a {@link Control} or collection of
  20179. * controls and returns a map of errors. A null map means that validation has passed.
  20180. *
  20181. * ### Example
  20182. *
  20183. * ```typescript
  20184. * var loginControl = new Control("", Validators.required)
  20185. * ```
  20186. */
  20187. var Validators = (function () {
  20188. function Validators() {
  20189. }
  20190. /**
  20191. * Validator that requires controls to have a non-empty value.
  20192. */
  20193. Validators.required = function (control) {
  20194. return lang_1.isBlank(control.value) || control.value == "" ? { "required": true } : null;
  20195. };
  20196. /**
  20197. * Validator that requires controls to have a value of a minimum length.
  20198. */
  20199. Validators.minLength = function (minLength) {
  20200. return function (control) {
  20201. if (lang_1.isPresent(Validators.required(control)))
  20202. return null;
  20203. var v = control.value;
  20204. return v.length < minLength ?
  20205. { "minlength": { "requiredLength": minLength, "actualLength": v.length } } :
  20206. null;
  20207. };
  20208. };
  20209. /**
  20210. * Validator that requires controls to have a value of a maximum length.
  20211. */
  20212. Validators.maxLength = function (maxLength) {
  20213. return function (control) {
  20214. if (lang_1.isPresent(Validators.required(control)))
  20215. return null;
  20216. var v = control.value;
  20217. return v.length > maxLength ?
  20218. { "maxlength": { "requiredLength": maxLength, "actualLength": v.length } } :
  20219. null;
  20220. };
  20221. };
  20222. /**
  20223. * No-op validator.
  20224. */
  20225. Validators.nullValidator = function (c) { return null; };
  20226. /**
  20227. * Compose multiple validators into a single function that returns the union
  20228. * of the individual error maps.
  20229. */
  20230. Validators.compose = function (validators) {
  20231. if (lang_1.isBlank(validators))
  20232. return null;
  20233. var presentValidators = validators.filter(lang_1.isPresent);
  20234. if (presentValidators.length == 0)
  20235. return null;
  20236. return function (control) {
  20237. return _mergeErrors(_executeValidators(control, presentValidators));
  20238. };
  20239. };
  20240. Validators.composeAsync = function (validators) {
  20241. if (lang_1.isBlank(validators))
  20242. return null;
  20243. var presentValidators = validators.filter(lang_1.isPresent);
  20244. if (presentValidators.length == 0)
  20245. return null;
  20246. return function (control) {
  20247. var promises = _executeValidators(control, presentValidators).map(_convertToPromise);
  20248. return promise_1.PromiseWrapper.all(promises).then(_mergeErrors);
  20249. };
  20250. };
  20251. return Validators;
  20252. })();
  20253. exports.Validators = Validators;
  20254. function _convertToPromise(obj) {
  20255. return promise_1.PromiseWrapper.isPromise(obj) ? obj : async_1.ObservableWrapper.toPromise(obj);
  20256. }
  20257. function _executeValidators(control, validators) {
  20258. return validators.map(function (v) { return v(control); });
  20259. }
  20260. function _mergeErrors(arrayOfErrors) {
  20261. var res = arrayOfErrors.reduce(function (res, errors) {
  20262. return lang_1.isPresent(errors) ? collection_1.StringMapWrapper.merge(res, errors) : res;
  20263. }, {});
  20264. return collection_1.StringMapWrapper.isEmpty(res) ? null : res;
  20265. }
  20266. /***/ },
  20267. /* 132 */
  20268. /***/ function(module, exports, __webpack_require__) {
  20269. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  20270. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20271. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  20272. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  20273. return c > 3 && r && Object.defineProperty(target, key, r), r;
  20274. };
  20275. var __metadata = (this && this.__metadata) || function (k, v) {
  20276. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  20277. };
  20278. var core_1 = __webpack_require__(2);
  20279. var control_value_accessor_1 = __webpack_require__(129);
  20280. var lang_1 = __webpack_require__(5);
  20281. var DEFAULT_VALUE_ACCESSOR = lang_1.CONST_EXPR(new core_1.Provider(control_value_accessor_1.NG_VALUE_ACCESSOR, { useExisting: core_1.forwardRef(function () { return DefaultValueAccessor; }), multi: true }));
  20282. /**
  20283. * The default accessor for writing a value and listening to changes that is used by the
  20284. * {@link NgModel}, {@link NgFormControl}, and {@link NgControlName} directives.
  20285. *
  20286. * ### Example
  20287. * ```
  20288. * <input type="text" ngControl="searchQuery">
  20289. * ```
  20290. */
  20291. var DefaultValueAccessor = (function () {
  20292. function DefaultValueAccessor(_renderer, _elementRef) {
  20293. this._renderer = _renderer;
  20294. this._elementRef = _elementRef;
  20295. this.onChange = function (_) { };
  20296. this.onTouched = function () { };
  20297. }
  20298. DefaultValueAccessor.prototype.writeValue = function (value) {
  20299. var normalizedValue = lang_1.isBlank(value) ? '' : value;
  20300. this._renderer.setElementProperty(this._elementRef, 'value', normalizedValue);
  20301. };
  20302. DefaultValueAccessor.prototype.registerOnChange = function (fn) { this.onChange = fn; };
  20303. DefaultValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
  20304. DefaultValueAccessor = __decorate([
  20305. core_1.Directive({
  20306. selector: 'input:not([type=checkbox])[ngControl],textarea[ngControl],input:not([type=checkbox])[ngFormControl],textarea[ngFormControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]',
  20307. // TODO: vsavkin replace the above selector with the one below it once
  20308. // https://github.com/angular/angular/issues/3011 is implemented
  20309. // selector: '[ngControl],[ngModel],[ngFormControl]',
  20310. host: { '(input)': 'onChange($event.target.value)', '(blur)': 'onTouched()' },
  20311. bindings: [DEFAULT_VALUE_ACCESSOR]
  20312. }),
  20313. __metadata('design:paramtypes', [core_1.Renderer, core_1.ElementRef])
  20314. ], DefaultValueAccessor);
  20315. return DefaultValueAccessor;
  20316. })();
  20317. exports.DefaultValueAccessor = DefaultValueAccessor;
  20318. /***/ },
  20319. /* 133 */
  20320. /***/ function(module, exports, __webpack_require__) {
  20321. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  20322. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20323. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  20324. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  20325. return c > 3 && r && Object.defineProperty(target, key, r), r;
  20326. };
  20327. var __metadata = (this && this.__metadata) || function (k, v) {
  20328. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  20329. };
  20330. var core_1 = __webpack_require__(2);
  20331. var control_value_accessor_1 = __webpack_require__(129);
  20332. var lang_1 = __webpack_require__(5);
  20333. var NUMBER_VALUE_ACCESSOR = lang_1.CONST_EXPR(new core_1.Provider(control_value_accessor_1.NG_VALUE_ACCESSOR, { useExisting: core_1.forwardRef(function () { return NumberValueAccessor; }), multi: true }));
  20334. /**
  20335. * The accessor for writing a number value and listening to changes that is used by the
  20336. * {@link NgModel}, {@link NgFormControl}, and {@link NgControlName} directives.
  20337. *
  20338. * ### Example
  20339. * ```
  20340. * <input type="number" [(ngModel)]="age">
  20341. * ```
  20342. */
  20343. var NumberValueAccessor = (function () {
  20344. function NumberValueAccessor(_renderer, _elementRef) {
  20345. this._renderer = _renderer;
  20346. this._elementRef = _elementRef;
  20347. this.onChange = function (_) { };
  20348. this.onTouched = function () { };
  20349. }
  20350. NumberValueAccessor.prototype.writeValue = function (value) {
  20351. this._renderer.setElementProperty(this._elementRef, 'value', value);
  20352. };
  20353. NumberValueAccessor.prototype.registerOnChange = function (fn) {
  20354. this.onChange = function (value) { fn(lang_1.NumberWrapper.parseFloat(value)); };
  20355. };
  20356. NumberValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
  20357. NumberValueAccessor = __decorate([
  20358. core_1.Directive({
  20359. selector: 'input[type=number][ngControl],input[type=number][ngFormControl],input[type=number][ngModel]',
  20360. host: {
  20361. '(change)': 'onChange($event.target.value)',
  20362. '(input)': 'onChange($event.target.value)',
  20363. '(blur)': 'onTouched()'
  20364. },
  20365. bindings: [NUMBER_VALUE_ACCESSOR]
  20366. }),
  20367. __metadata('design:paramtypes', [core_1.Renderer, core_1.ElementRef])
  20368. ], NumberValueAccessor);
  20369. return NumberValueAccessor;
  20370. })();
  20371. exports.NumberValueAccessor = NumberValueAccessor;
  20372. /***/ },
  20373. /* 134 */
  20374. /***/ function(module, exports, __webpack_require__) {
  20375. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  20376. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20377. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  20378. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  20379. return c > 3 && r && Object.defineProperty(target, key, r), r;
  20380. };
  20381. var __metadata = (this && this.__metadata) || function (k, v) {
  20382. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  20383. };
  20384. var core_1 = __webpack_require__(2);
  20385. var control_value_accessor_1 = __webpack_require__(129);
  20386. var lang_1 = __webpack_require__(5);
  20387. var CHECKBOX_VALUE_ACCESSOR = lang_1.CONST_EXPR(new core_1.Provider(control_value_accessor_1.NG_VALUE_ACCESSOR, { useExisting: core_1.forwardRef(function () { return CheckboxControlValueAccessor; }), multi: true }));
  20388. /**
  20389. * The accessor for writing a value and listening to changes on a checkbox input element.
  20390. *
  20391. * ### Example
  20392. * ```
  20393. * <input type="checkbox" ngControl="rememberLogin">
  20394. * ```
  20395. */
  20396. var CheckboxControlValueAccessor = (function () {
  20397. function CheckboxControlValueAccessor(_renderer, _elementRef) {
  20398. this._renderer = _renderer;
  20399. this._elementRef = _elementRef;
  20400. this.onChange = function (_) { };
  20401. this.onTouched = function () { };
  20402. }
  20403. CheckboxControlValueAccessor.prototype.writeValue = function (value) {
  20404. this._renderer.setElementProperty(this._elementRef, 'checked', value);
  20405. };
  20406. CheckboxControlValueAccessor.prototype.registerOnChange = function (fn) { this.onChange = fn; };
  20407. CheckboxControlValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
  20408. CheckboxControlValueAccessor = __decorate([
  20409. core_1.Directive({
  20410. selector: 'input[type=checkbox][ngControl],input[type=checkbox][ngFormControl],input[type=checkbox][ngModel]',
  20411. host: { '(change)': 'onChange($event.target.checked)', '(blur)': 'onTouched()' },
  20412. bindings: [CHECKBOX_VALUE_ACCESSOR]
  20413. }),
  20414. __metadata('design:paramtypes', [core_1.Renderer, core_1.ElementRef])
  20415. ], CheckboxControlValueAccessor);
  20416. return CheckboxControlValueAccessor;
  20417. })();
  20418. exports.CheckboxControlValueAccessor = CheckboxControlValueAccessor;
  20419. /***/ },
  20420. /* 135 */
  20421. /***/ function(module, exports, __webpack_require__) {
  20422. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  20423. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20424. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  20425. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  20426. return c > 3 && r && Object.defineProperty(target, key, r), r;
  20427. };
  20428. var __metadata = (this && this.__metadata) || function (k, v) {
  20429. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  20430. };
  20431. var __param = (this && this.__param) || function (paramIndex, decorator) {
  20432. return function (target, key) { decorator(target, key, paramIndex); }
  20433. };
  20434. var core_1 = __webpack_require__(2);
  20435. var async_1 = __webpack_require__(60);
  20436. var control_value_accessor_1 = __webpack_require__(129);
  20437. var lang_1 = __webpack_require__(5);
  20438. var SELECT_VALUE_ACCESSOR = lang_1.CONST_EXPR(new core_1.Provider(control_value_accessor_1.NG_VALUE_ACCESSOR, { useExisting: core_1.forwardRef(function () { return SelectControlValueAccessor; }), multi: true }));
  20439. /**
  20440. * Marks `<option>` as dynamic, so Angular can be notified when options change.
  20441. *
  20442. * ### Example
  20443. *
  20444. * ```
  20445. * <select ngControl="city">
  20446. * <option *ngFor="#c of cities" [value]="c"></option>
  20447. * </select>
  20448. * ```
  20449. */
  20450. var NgSelectOption = (function () {
  20451. function NgSelectOption() {
  20452. }
  20453. NgSelectOption = __decorate([
  20454. core_1.Directive({ selector: 'option' }),
  20455. __metadata('design:paramtypes', [])
  20456. ], NgSelectOption);
  20457. return NgSelectOption;
  20458. })();
  20459. exports.NgSelectOption = NgSelectOption;
  20460. /**
  20461. * The accessor for writing a value and listening to changes on a select element.
  20462. */
  20463. var SelectControlValueAccessor = (function () {
  20464. function SelectControlValueAccessor(_renderer, _elementRef, query) {
  20465. this._renderer = _renderer;
  20466. this._elementRef = _elementRef;
  20467. this.onChange = function (_) { };
  20468. this.onTouched = function () { };
  20469. this._updateValueWhenListOfOptionsChanges(query);
  20470. }
  20471. SelectControlValueAccessor.prototype.writeValue = function (value) {
  20472. this.value = value;
  20473. this._renderer.setElementProperty(this._elementRef, 'value', value);
  20474. };
  20475. SelectControlValueAccessor.prototype.registerOnChange = function (fn) { this.onChange = fn; };
  20476. SelectControlValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
  20477. SelectControlValueAccessor.prototype._updateValueWhenListOfOptionsChanges = function (query) {
  20478. var _this = this;
  20479. async_1.ObservableWrapper.subscribe(query.changes, function (_) { return _this.writeValue(_this.value); });
  20480. };
  20481. SelectControlValueAccessor = __decorate([
  20482. core_1.Directive({
  20483. selector: 'select[ngControl],select[ngFormControl],select[ngModel]',
  20484. host: {
  20485. '(change)': 'onChange($event.target.value)',
  20486. '(input)': 'onChange($event.target.value)',
  20487. '(blur)': 'onTouched()'
  20488. },
  20489. bindings: [SELECT_VALUE_ACCESSOR]
  20490. }),
  20491. __param(2, core_1.Query(NgSelectOption, { descendants: true })),
  20492. __metadata('design:paramtypes', [core_1.Renderer, core_1.ElementRef, core_1.QueryList])
  20493. ], SelectControlValueAccessor);
  20494. return SelectControlValueAccessor;
  20495. })();
  20496. exports.SelectControlValueAccessor = SelectControlValueAccessor;
  20497. /***/ },
  20498. /* 136 */
  20499. /***/ function(module, exports) {
  20500. function normalizeValidator(validator) {
  20501. if (validator.validate !== undefined) {
  20502. return function (c) { return validator.validate(c); };
  20503. }
  20504. else {
  20505. return validator;
  20506. }
  20507. }
  20508. exports.normalizeValidator = normalizeValidator;
  20509. /***/ },
  20510. /* 137 */
  20511. /***/ function(module, exports, __webpack_require__) {
  20512. var __extends = (this && this.__extends) || function (d, b) {
  20513. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  20514. function __() { this.constructor = d; }
  20515. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20516. };
  20517. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  20518. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20519. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  20520. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  20521. return c > 3 && r && Object.defineProperty(target, key, r), r;
  20522. };
  20523. var __metadata = (this && this.__metadata) || function (k, v) {
  20524. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  20525. };
  20526. var __param = (this && this.__param) || function (paramIndex, decorator) {
  20527. return function (target, key) { decorator(target, key, paramIndex); }
  20528. };
  20529. var lang_1 = __webpack_require__(5);
  20530. var collection_1 = __webpack_require__(12);
  20531. var async_1 = __webpack_require__(60);
  20532. var core_1 = __webpack_require__(2);
  20533. var ng_control_1 = __webpack_require__(128);
  20534. var validators_1 = __webpack_require__(131);
  20535. var control_value_accessor_1 = __webpack_require__(129);
  20536. var shared_1 = __webpack_require__(130);
  20537. var formControlBinding = lang_1.CONST_EXPR(new core_1.Provider(ng_control_1.NgControl, { useExisting: core_1.forwardRef(function () { return NgFormControl; }) }));
  20538. /**
  20539. * Binds an existing {@link Control} to a DOM element.
  20540. *
  20541. * ### Example ([live demo](http://plnkr.co/edit/jcQlZ2tTh22BZZ2ucNAT?p=preview))
  20542. *
  20543. * In this example, we bind the control to an input element. When the value of the input element
  20544. * changes, the value of the control will reflect that change. Likewise, if the value of the
  20545. * control changes, the input element reflects that change.
  20546. *
  20547. * ```typescript
  20548. * @Component({
  20549. * selector: 'my-app',
  20550. * template: `
  20551. * <div>
  20552. * <h2>NgFormControl Example</h2>
  20553. * <form>
  20554. * <p>Element with existing control: <input type="text"
  20555. * [ngFormControl]="loginControl"></p>
  20556. * <p>Value of existing control: {{loginControl.value}}</p>
  20557. * </form>
  20558. * </div>
  20559. * `,
  20560. * directives: [CORE_DIRECTIVES, FORM_DIRECTIVES]
  20561. * })
  20562. * export class App {
  20563. * loginControl: Control = new Control('');
  20564. * }
  20565. * ```
  20566. *
  20567. * ###ngModel
  20568. *
  20569. * We can also use `ngModel` to bind a domain model to the form.
  20570. *
  20571. * ### Example ([live demo](http://plnkr.co/edit/yHMLuHO7DNgT8XvtjTDH?p=preview))
  20572. *
  20573. * ```typescript
  20574. * @Component({
  20575. * selector: "login-comp",
  20576. * directives: [FORM_DIRECTIVES],
  20577. * template: "<input type='text' [ngFormControl]='loginControl' [(ngModel)]='login'>"
  20578. * })
  20579. * class LoginComp {
  20580. * loginControl: Control = new Control('');
  20581. * login:string;
  20582. * }
  20583. * ```
  20584. */
  20585. var NgFormControl = (function (_super) {
  20586. __extends(NgFormControl, _super);
  20587. function NgFormControl(_validators, _asyncValidators, valueAccessors) {
  20588. _super.call(this);
  20589. this._validators = _validators;
  20590. this._asyncValidators = _asyncValidators;
  20591. this.update = new async_1.EventEmitter();
  20592. this.valueAccessor = shared_1.selectValueAccessor(this, valueAccessors);
  20593. }
  20594. NgFormControl.prototype.ngOnChanges = function (changes) {
  20595. if (this._isControlChanged(changes)) {
  20596. shared_1.setUpControl(this.form, this);
  20597. this.form.updateValueAndValidity({ emitEvent: false });
  20598. }
  20599. if (shared_1.isPropertyUpdated(changes, this.viewModel)) {
  20600. this.form.updateValue(this.model);
  20601. this.viewModel = this.model;
  20602. }
  20603. };
  20604. Object.defineProperty(NgFormControl.prototype, "path", {
  20605. get: function () { return []; },
  20606. enumerable: true,
  20607. configurable: true
  20608. });
  20609. Object.defineProperty(NgFormControl.prototype, "validator", {
  20610. get: function () { return shared_1.composeValidators(this._validators); },
  20611. enumerable: true,
  20612. configurable: true
  20613. });
  20614. Object.defineProperty(NgFormControl.prototype, "asyncValidator", {
  20615. get: function () { return shared_1.composeAsyncValidators(this._asyncValidators); },
  20616. enumerable: true,
  20617. configurable: true
  20618. });
  20619. Object.defineProperty(NgFormControl.prototype, "control", {
  20620. get: function () { return this.form; },
  20621. enumerable: true,
  20622. configurable: true
  20623. });
  20624. NgFormControl.prototype.viewToModelUpdate = function (newValue) {
  20625. this.viewModel = newValue;
  20626. async_1.ObservableWrapper.callEmit(this.update, newValue);
  20627. };
  20628. NgFormControl.prototype._isControlChanged = function (changes) {
  20629. return collection_1.StringMapWrapper.contains(changes, "form");
  20630. };
  20631. NgFormControl = __decorate([
  20632. core_1.Directive({
  20633. selector: '[ngFormControl]',
  20634. bindings: [formControlBinding],
  20635. inputs: ['form: ngFormControl', 'model: ngModel'],
  20636. outputs: ['update: ngModelChange'],
  20637. exportAs: 'ngForm'
  20638. }),
  20639. __param(0, core_1.Optional()),
  20640. __param(0, core_1.Self()),
  20641. __param(0, core_1.Inject(validators_1.NG_VALIDATORS)),
  20642. __param(1, core_1.Optional()),
  20643. __param(1, core_1.Self()),
  20644. __param(1, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)),
  20645. __param(2, core_1.Optional()),
  20646. __param(2, core_1.Self()),
  20647. __param(2, core_1.Inject(control_value_accessor_1.NG_VALUE_ACCESSOR)),
  20648. __metadata('design:paramtypes', [Array, Array, Array])
  20649. ], NgFormControl);
  20650. return NgFormControl;
  20651. })(ng_control_1.NgControl);
  20652. exports.NgFormControl = NgFormControl;
  20653. /***/ },
  20654. /* 138 */
  20655. /***/ function(module, exports, __webpack_require__) {
  20656. var __extends = (this && this.__extends) || function (d, b) {
  20657. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  20658. function __() { this.constructor = d; }
  20659. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20660. };
  20661. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  20662. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20663. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  20664. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  20665. return c > 3 && r && Object.defineProperty(target, key, r), r;
  20666. };
  20667. var __metadata = (this && this.__metadata) || function (k, v) {
  20668. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  20669. };
  20670. var __param = (this && this.__param) || function (paramIndex, decorator) {
  20671. return function (target, key) { decorator(target, key, paramIndex); }
  20672. };
  20673. var lang_1 = __webpack_require__(5);
  20674. var async_1 = __webpack_require__(60);
  20675. var core_1 = __webpack_require__(2);
  20676. var control_value_accessor_1 = __webpack_require__(129);
  20677. var ng_control_1 = __webpack_require__(128);
  20678. var model_1 = __webpack_require__(124);
  20679. var validators_1 = __webpack_require__(131);
  20680. var shared_1 = __webpack_require__(130);
  20681. var formControlBinding = lang_1.CONST_EXPR(new core_1.Provider(ng_control_1.NgControl, { useExisting: core_1.forwardRef(function () { return NgModel; }) }));
  20682. /**
  20683. * Binds a domain model to a form control.
  20684. *
  20685. * ### Usage
  20686. *
  20687. * `ngModel` binds an existing domain model to a form control. For a
  20688. * two-way binding, use `[(ngModel)]` to ensure the model updates in
  20689. * both directions.
  20690. *
  20691. * ### Example ([live demo](http://plnkr.co/edit/R3UX5qDaUqFO2VYR0UzH?p=preview))
  20692. * ```typescript
  20693. * @Component({
  20694. * selector: "search-comp",
  20695. * directives: [FORM_DIRECTIVES],
  20696. * template: `<input type='text' [(ngModel)]="searchQuery">`
  20697. * })
  20698. * class SearchComp {
  20699. * searchQuery: string;
  20700. * }
  20701. * ```
  20702. */
  20703. var NgModel = (function (_super) {
  20704. __extends(NgModel, _super);
  20705. function NgModel(_validators, _asyncValidators, valueAccessors) {
  20706. _super.call(this);
  20707. this._validators = _validators;
  20708. this._asyncValidators = _asyncValidators;
  20709. /** @internal */
  20710. this._control = new model_1.Control();
  20711. /** @internal */
  20712. this._added = false;
  20713. this.update = new async_1.EventEmitter();
  20714. this.valueAccessor = shared_1.selectValueAccessor(this, valueAccessors);
  20715. }
  20716. NgModel.prototype.ngOnChanges = function (changes) {
  20717. if (!this._added) {
  20718. shared_1.setUpControl(this._control, this);
  20719. this._control.updateValueAndValidity({ emitEvent: false });
  20720. this._added = true;
  20721. }
  20722. if (shared_1.isPropertyUpdated(changes, this.viewModel)) {
  20723. this._control.updateValue(this.model);
  20724. this.viewModel = this.model;
  20725. }
  20726. };
  20727. Object.defineProperty(NgModel.prototype, "control", {
  20728. get: function () { return this._control; },
  20729. enumerable: true,
  20730. configurable: true
  20731. });
  20732. Object.defineProperty(NgModel.prototype, "path", {
  20733. get: function () { return []; },
  20734. enumerable: true,
  20735. configurable: true
  20736. });
  20737. Object.defineProperty(NgModel.prototype, "validator", {
  20738. get: function () { return shared_1.composeValidators(this._validators); },
  20739. enumerable: true,
  20740. configurable: true
  20741. });
  20742. Object.defineProperty(NgModel.prototype, "asyncValidator", {
  20743. get: function () { return shared_1.composeAsyncValidators(this._asyncValidators); },
  20744. enumerable: true,
  20745. configurable: true
  20746. });
  20747. NgModel.prototype.viewToModelUpdate = function (newValue) {
  20748. this.viewModel = newValue;
  20749. async_1.ObservableWrapper.callEmit(this.update, newValue);
  20750. };
  20751. NgModel = __decorate([
  20752. core_1.Directive({
  20753. selector: '[ngModel]:not([ngControl]):not([ngFormControl])',
  20754. bindings: [formControlBinding],
  20755. inputs: ['model: ngModel'],
  20756. outputs: ['update: ngModelChange'],
  20757. exportAs: 'ngForm'
  20758. }),
  20759. __param(0, core_1.Optional()),
  20760. __param(0, core_1.Self()),
  20761. __param(0, core_1.Inject(validators_1.NG_VALIDATORS)),
  20762. __param(1, core_1.Optional()),
  20763. __param(1, core_1.Self()),
  20764. __param(1, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)),
  20765. __param(2, core_1.Optional()),
  20766. __param(2, core_1.Self()),
  20767. __param(2, core_1.Inject(control_value_accessor_1.NG_VALUE_ACCESSOR)),
  20768. __metadata('design:paramtypes', [Array, Array, Array])
  20769. ], NgModel);
  20770. return NgModel;
  20771. })(ng_control_1.NgControl);
  20772. exports.NgModel = NgModel;
  20773. /***/ },
  20774. /* 139 */
  20775. /***/ function(module, exports, __webpack_require__) {
  20776. var __extends = (this && this.__extends) || function (d, b) {
  20777. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  20778. function __() { this.constructor = d; }
  20779. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20780. };
  20781. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  20782. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20783. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  20784. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  20785. return c > 3 && r && Object.defineProperty(target, key, r), r;
  20786. };
  20787. var __metadata = (this && this.__metadata) || function (k, v) {
  20788. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  20789. };
  20790. var __param = (this && this.__param) || function (paramIndex, decorator) {
  20791. return function (target, key) { decorator(target, key, paramIndex); }
  20792. };
  20793. var core_1 = __webpack_require__(2);
  20794. var lang_1 = __webpack_require__(5);
  20795. var control_container_1 = __webpack_require__(126);
  20796. var shared_1 = __webpack_require__(130);
  20797. var validators_1 = __webpack_require__(131);
  20798. var controlGroupProvider = lang_1.CONST_EXPR(new core_1.Provider(control_container_1.ControlContainer, { useExisting: core_1.forwardRef(function () { return NgControlGroup; }) }));
  20799. /**
  20800. * Creates and binds a control group to a DOM element.
  20801. *
  20802. * This directive can only be used as a child of {@link NgForm} or {@link NgFormModel}.
  20803. *
  20804. * ### Example ([live demo](http://plnkr.co/edit/7EJ11uGeaggViYM6T5nq?p=preview))
  20805. *
  20806. * ```typescript
  20807. * @Component({
  20808. * selector: 'my-app',
  20809. * directives: [FORM_DIRECTIVES],
  20810. * })
  20811. * @View({
  20812. * template: `
  20813. * <div>
  20814. * <h2>Angular2 Control &amp; ControlGroup Example</h2>
  20815. * <form #f="ngForm">
  20816. * <div ngControlGroup="name" #cg-name="form">
  20817. * <h3>Enter your name:</h3>
  20818. * <p>First: <input ngControl="first" required></p>
  20819. * <p>Middle: <input ngControl="middle"></p>
  20820. * <p>Last: <input ngControl="last" required></p>
  20821. * </div>
  20822. * <h3>Name value:</h3>
  20823. * <pre>{{valueOf(cgName)}}</pre>
  20824. * <p>Name is {{cgName?.control?.valid ? "valid" : "invalid"}}</p>
  20825. * <h3>What's your favorite food?</h3>
  20826. * <p><input ngControl="food"></p>
  20827. * <h3>Form value</h3>
  20828. * <pre>{{valueOf(f)}}</pre>
  20829. * </form>
  20830. * </div>
  20831. * `,
  20832. * directives: [FORM_DIRECTIVES]
  20833. * })
  20834. * export class App {
  20835. * valueOf(cg: NgControlGroup): string {
  20836. * if (cg.control == null) {
  20837. * return null;
  20838. * }
  20839. * return JSON.stringify(cg.control.value, null, 2);
  20840. * }
  20841. * }
  20842. * ```
  20843. *
  20844. * This example declares a control group for a user's name. The value and validation state of
  20845. * this group can be accessed separately from the overall form.
  20846. */
  20847. var NgControlGroup = (function (_super) {
  20848. __extends(NgControlGroup, _super);
  20849. function NgControlGroup(parent, _validators, _asyncValidators) {
  20850. _super.call(this);
  20851. this._validators = _validators;
  20852. this._asyncValidators = _asyncValidators;
  20853. this._parent = parent;
  20854. }
  20855. NgControlGroup.prototype.ngOnInit = function () { this.formDirective.addControlGroup(this); };
  20856. NgControlGroup.prototype.ngOnDestroy = function () { this.formDirective.removeControlGroup(this); };
  20857. Object.defineProperty(NgControlGroup.prototype, "control", {
  20858. /**
  20859. * Get the {@link ControlGroup} backing this binding.
  20860. */
  20861. get: function () { return this.formDirective.getControlGroup(this); },
  20862. enumerable: true,
  20863. configurable: true
  20864. });
  20865. Object.defineProperty(NgControlGroup.prototype, "path", {
  20866. /**
  20867. * Get the path to this control group.
  20868. */
  20869. get: function () { return shared_1.controlPath(this.name, this._parent); },
  20870. enumerable: true,
  20871. configurable: true
  20872. });
  20873. Object.defineProperty(NgControlGroup.prototype, "formDirective", {
  20874. /**
  20875. * Get the {@link Form} to which this group belongs.
  20876. */
  20877. get: function () { return this._parent.formDirective; },
  20878. enumerable: true,
  20879. configurable: true
  20880. });
  20881. Object.defineProperty(NgControlGroup.prototype, "validator", {
  20882. get: function () { return shared_1.composeValidators(this._validators); },
  20883. enumerable: true,
  20884. configurable: true
  20885. });
  20886. Object.defineProperty(NgControlGroup.prototype, "asyncValidator", {
  20887. get: function () { return shared_1.composeAsyncValidators(this._asyncValidators); },
  20888. enumerable: true,
  20889. configurable: true
  20890. });
  20891. NgControlGroup = __decorate([
  20892. core_1.Directive({
  20893. selector: '[ngControlGroup]',
  20894. providers: [controlGroupProvider],
  20895. inputs: ['name: ngControlGroup'],
  20896. exportAs: 'ngForm'
  20897. }),
  20898. __param(0, core_1.Host()),
  20899. __param(0, core_1.SkipSelf()),
  20900. __param(1, core_1.Optional()),
  20901. __param(1, core_1.Self()),
  20902. __param(1, core_1.Inject(validators_1.NG_VALIDATORS)),
  20903. __param(2, core_1.Optional()),
  20904. __param(2, core_1.Self()),
  20905. __param(2, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)),
  20906. __metadata('design:paramtypes', [control_container_1.ControlContainer, Array, Array])
  20907. ], NgControlGroup);
  20908. return NgControlGroup;
  20909. })(control_container_1.ControlContainer);
  20910. exports.NgControlGroup = NgControlGroup;
  20911. /***/ },
  20912. /* 140 */
  20913. /***/ function(module, exports, __webpack_require__) {
  20914. var __extends = (this && this.__extends) || function (d, b) {
  20915. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  20916. function __() { this.constructor = d; }
  20917. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20918. };
  20919. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  20920. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20921. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  20922. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  20923. return c > 3 && r && Object.defineProperty(target, key, r), r;
  20924. };
  20925. var __metadata = (this && this.__metadata) || function (k, v) {
  20926. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  20927. };
  20928. var __param = (this && this.__param) || function (paramIndex, decorator) {
  20929. return function (target, key) { decorator(target, key, paramIndex); }
  20930. };
  20931. var lang_1 = __webpack_require__(5);
  20932. var collection_1 = __webpack_require__(12);
  20933. var async_1 = __webpack_require__(60);
  20934. var core_1 = __webpack_require__(2);
  20935. var control_container_1 = __webpack_require__(126);
  20936. var shared_1 = __webpack_require__(130);
  20937. var validators_1 = __webpack_require__(131);
  20938. var formDirectiveProvider = lang_1.CONST_EXPR(new core_1.Provider(control_container_1.ControlContainer, { useExisting: core_1.forwardRef(function () { return NgFormModel; }) }));
  20939. /**
  20940. * Binds an existing control group to a DOM element.
  20941. *
  20942. * ### Example ([live demo](http://plnkr.co/edit/jqrVirudY8anJxTMUjTP?p=preview))
  20943. *
  20944. * In this example, we bind the control group to the form element, and we bind the login and
  20945. * password controls to the login and password elements.
  20946. *
  20947. * ```typescript
  20948. * @Component({
  20949. * selector: 'my-app',
  20950. * template: `
  20951. * <div>
  20952. * <h2>NgFormModel Example</h2>
  20953. * <form [ngFormModel]="loginForm">
  20954. * <p>Login: <input type="text" ngControl="login"></p>
  20955. * <p>Password: <input type="password" ngControl="password"></p>
  20956. * </form>
  20957. * <p>Value:</p>
  20958. * <pre>{{value}}</pre>
  20959. * </div>
  20960. * `,
  20961. * directives: [FORM_DIRECTIVES]
  20962. * })
  20963. * export class App {
  20964. * loginForm: ControlGroup;
  20965. *
  20966. * constructor() {
  20967. * this.loginForm = new ControlGroup({
  20968. * login: new Control(""),
  20969. * password: new Control("")
  20970. * });
  20971. * }
  20972. *
  20973. * get value(): string {
  20974. * return JSON.stringify(this.loginForm.value, null, 2);
  20975. * }
  20976. * }
  20977. * ```
  20978. *
  20979. * We can also use ngModel to bind a domain model to the form.
  20980. *
  20981. * ```typescript
  20982. * @Component({
  20983. * selector: "login-comp",
  20984. * directives: [FORM_DIRECTIVES],
  20985. * template: `
  20986. * <form [ngFormModel]='loginForm'>
  20987. * Login <input type='text' ngControl='login' [(ngModel)]='credentials.login'>
  20988. * Password <input type='password' ngControl='password'
  20989. * [(ngModel)]='credentials.password'>
  20990. * <button (click)="onLogin()">Login</button>
  20991. * </form>`
  20992. * })
  20993. * class LoginComp {
  20994. * credentials: {login: string, password: string};
  20995. * loginForm: ControlGroup;
  20996. *
  20997. * constructor() {
  20998. * this.loginForm = new ControlGroup({
  20999. * login: new Control(""),
  21000. * password: new Control("")
  21001. * });
  21002. * }
  21003. *
  21004. * onLogin(): void {
  21005. * // this.credentials.login === 'some login'
  21006. * // this.credentials.password === 'some password'
  21007. * }
  21008. * }
  21009. * ```
  21010. */
  21011. var NgFormModel = (function (_super) {
  21012. __extends(NgFormModel, _super);
  21013. function NgFormModel(_validators, _asyncValidators) {
  21014. _super.call(this);
  21015. this._validators = _validators;
  21016. this._asyncValidators = _asyncValidators;
  21017. this.form = null;
  21018. this.directives = [];
  21019. this.ngSubmit = new async_1.EventEmitter();
  21020. }
  21021. NgFormModel.prototype.ngOnChanges = function (changes) {
  21022. if (collection_1.StringMapWrapper.contains(changes, "form")) {
  21023. var sync = shared_1.composeValidators(this._validators);
  21024. this.form.validator = validators_1.Validators.compose([this.form.validator, sync]);
  21025. var async = shared_1.composeAsyncValidators(this._asyncValidators);
  21026. this.form.asyncValidator = validators_1.Validators.composeAsync([this.form.asyncValidator, async]);
  21027. this.form.updateValueAndValidity({ onlySelf: true, emitEvent: false });
  21028. }
  21029. this._updateDomValue();
  21030. };
  21031. Object.defineProperty(NgFormModel.prototype, "formDirective", {
  21032. get: function () { return this; },
  21033. enumerable: true,
  21034. configurable: true
  21035. });
  21036. Object.defineProperty(NgFormModel.prototype, "control", {
  21037. get: function () { return this.form; },
  21038. enumerable: true,
  21039. configurable: true
  21040. });
  21041. Object.defineProperty(NgFormModel.prototype, "path", {
  21042. get: function () { return []; },
  21043. enumerable: true,
  21044. configurable: true
  21045. });
  21046. NgFormModel.prototype.addControl = function (dir) {
  21047. var ctrl = this.form.find(dir.path);
  21048. shared_1.setUpControl(ctrl, dir);
  21049. ctrl.updateValueAndValidity({ emitEvent: false });
  21050. this.directives.push(dir);
  21051. };
  21052. NgFormModel.prototype.getControl = function (dir) { return this.form.find(dir.path); };
  21053. NgFormModel.prototype.removeControl = function (dir) { collection_1.ListWrapper.remove(this.directives, dir); };
  21054. NgFormModel.prototype.addControlGroup = function (dir) {
  21055. var ctrl = this.form.find(dir.path);
  21056. shared_1.setUpControlGroup(ctrl, dir);
  21057. ctrl.updateValueAndValidity({ emitEvent: false });
  21058. };
  21059. NgFormModel.prototype.removeControlGroup = function (dir) { };
  21060. NgFormModel.prototype.getControlGroup = function (dir) {
  21061. return this.form.find(dir.path);
  21062. };
  21063. NgFormModel.prototype.updateModel = function (dir, value) {
  21064. var ctrl = this.form.find(dir.path);
  21065. ctrl.updateValue(value);
  21066. };
  21067. NgFormModel.prototype.onSubmit = function () {
  21068. async_1.ObservableWrapper.callEmit(this.ngSubmit, null);
  21069. return false;
  21070. };
  21071. /** @internal */
  21072. NgFormModel.prototype._updateDomValue = function () {
  21073. var _this = this;
  21074. this.directives.forEach(function (dir) {
  21075. var ctrl = _this.form.find(dir.path);
  21076. dir.valueAccessor.writeValue(ctrl.value);
  21077. });
  21078. };
  21079. NgFormModel = __decorate([
  21080. core_1.Directive({
  21081. selector: '[ngFormModel]',
  21082. bindings: [formDirectiveProvider],
  21083. inputs: ['form: ngFormModel'],
  21084. host: { '(submit)': 'onSubmit()' },
  21085. outputs: ['ngSubmit'],
  21086. exportAs: 'ngForm'
  21087. }),
  21088. __param(0, core_1.Optional()),
  21089. __param(0, core_1.Self()),
  21090. __param(0, core_1.Inject(validators_1.NG_VALIDATORS)),
  21091. __param(1, core_1.Optional()),
  21092. __param(1, core_1.Self()),
  21093. __param(1, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)),
  21094. __metadata('design:paramtypes', [Array, Array])
  21095. ], NgFormModel);
  21096. return NgFormModel;
  21097. })(control_container_1.ControlContainer);
  21098. exports.NgFormModel = NgFormModel;
  21099. /***/ },
  21100. /* 141 */
  21101. /***/ function(module, exports, __webpack_require__) {
  21102. var __extends = (this && this.__extends) || function (d, b) {
  21103. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  21104. function __() { this.constructor = d; }
  21105. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  21106. };
  21107. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  21108. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  21109. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21110. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  21111. return c > 3 && r && Object.defineProperty(target, key, r), r;
  21112. };
  21113. var __metadata = (this && this.__metadata) || function (k, v) {
  21114. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  21115. };
  21116. var __param = (this && this.__param) || function (paramIndex, decorator) {
  21117. return function (target, key) { decorator(target, key, paramIndex); }
  21118. };
  21119. var async_1 = __webpack_require__(60);
  21120. var collection_1 = __webpack_require__(12);
  21121. var lang_1 = __webpack_require__(5);
  21122. var core_1 = __webpack_require__(2);
  21123. var control_container_1 = __webpack_require__(126);
  21124. var model_1 = __webpack_require__(124);
  21125. var shared_1 = __webpack_require__(130);
  21126. var validators_1 = __webpack_require__(131);
  21127. var formDirectiveProvider = lang_1.CONST_EXPR(new core_1.Provider(control_container_1.ControlContainer, { useExisting: core_1.forwardRef(function () { return NgForm; }) }));
  21128. /**
  21129. * If `NgForm` is bound in a component, `<form>` elements in that component will be
  21130. * upgraded to use the Angular form system.
  21131. *
  21132. * ### Typical Use
  21133. *
  21134. * Include `FORM_DIRECTIVES` in the `directives` section of a {@link View} annotation
  21135. * to use `NgForm` and its associated controls.
  21136. *
  21137. * ### Structure
  21138. *
  21139. * An Angular form is a collection of `Control`s in some hierarchy.
  21140. * `Control`s can be at the top level or can be organized in `ControlGroup`s
  21141. * or `ControlArray`s. This hierarchy is reflected in the form's `value`, a
  21142. * JSON object that mirrors the form structure.
  21143. *
  21144. * ### Submission
  21145. *
  21146. * The `ngSubmit` event signals when the user triggers a form submission.
  21147. *
  21148. * ### Example ([live demo](http://plnkr.co/edit/ltdgYj4P0iY64AR71EpL?p=preview))
  21149. *
  21150. * ```typescript
  21151. * @Component({
  21152. * selector: 'my-app',
  21153. * template: `
  21154. * <div>
  21155. * <p>Submit the form to see the data object Angular builds</p>
  21156. * <h2>NgForm demo</h2>
  21157. * <form #f="ngForm" (ngSubmit)="onSubmit(f.value)">
  21158. * <h3>Control group: credentials</h3>
  21159. * <div ngControlGroup="credentials">
  21160. * <p>Login: <input type="text" ngControl="login"></p>
  21161. * <p>Password: <input type="password" ngControl="password"></p>
  21162. * </div>
  21163. * <h3>Control group: person</h3>
  21164. * <div ngControlGroup="person">
  21165. * <p>First name: <input type="text" ngControl="firstName"></p>
  21166. * <p>Last name: <input type="text" ngControl="lastName"></p>
  21167. * </div>
  21168. * <button type="submit">Submit Form</button>
  21169. * <p>Form data submitted:</p>
  21170. * </form>
  21171. * <pre>{{data}}</pre>
  21172. * </div>
  21173. * `,
  21174. * directives: [CORE_DIRECTIVES, FORM_DIRECTIVES]
  21175. * })
  21176. * export class App {
  21177. * constructor() {}
  21178. *
  21179. * data: string;
  21180. *
  21181. * onSubmit(data) {
  21182. * this.data = JSON.stringify(data, null, 2);
  21183. * }
  21184. * }
  21185. * ```
  21186. */
  21187. var NgForm = (function (_super) {
  21188. __extends(NgForm, _super);
  21189. function NgForm(validators, asyncValidators) {
  21190. _super.call(this);
  21191. this.ngSubmit = new async_1.EventEmitter();
  21192. this.form = new model_1.ControlGroup({}, null, shared_1.composeValidators(validators), shared_1.composeAsyncValidators(asyncValidators));
  21193. }
  21194. Object.defineProperty(NgForm.prototype, "formDirective", {
  21195. get: function () { return this; },
  21196. enumerable: true,
  21197. configurable: true
  21198. });
  21199. Object.defineProperty(NgForm.prototype, "control", {
  21200. get: function () { return this.form; },
  21201. enumerable: true,
  21202. configurable: true
  21203. });
  21204. Object.defineProperty(NgForm.prototype, "path", {
  21205. get: function () { return []; },
  21206. enumerable: true,
  21207. configurable: true
  21208. });
  21209. Object.defineProperty(NgForm.prototype, "controls", {
  21210. get: function () { return this.form.controls; },
  21211. enumerable: true,
  21212. configurable: true
  21213. });
  21214. NgForm.prototype.addControl = function (dir) {
  21215. var _this = this;
  21216. async_1.PromiseWrapper.scheduleMicrotask(function () {
  21217. var container = _this._findContainer(dir.path);
  21218. var ctrl = new model_1.Control();
  21219. shared_1.setUpControl(ctrl, dir);
  21220. container.addControl(dir.name, ctrl);
  21221. ctrl.updateValueAndValidity({ emitEvent: false });
  21222. });
  21223. };
  21224. NgForm.prototype.getControl = function (dir) { return this.form.find(dir.path); };
  21225. NgForm.prototype.removeControl = function (dir) {
  21226. var _this = this;
  21227. async_1.PromiseWrapper.scheduleMicrotask(function () {
  21228. var container = _this._findContainer(dir.path);
  21229. if (lang_1.isPresent(container)) {
  21230. container.removeControl(dir.name);
  21231. container.updateValueAndValidity({ emitEvent: false });
  21232. }
  21233. });
  21234. };
  21235. NgForm.prototype.addControlGroup = function (dir) {
  21236. var _this = this;
  21237. async_1.PromiseWrapper.scheduleMicrotask(function () {
  21238. var container = _this._findContainer(dir.path);
  21239. var group = new model_1.ControlGroup({});
  21240. shared_1.setUpControlGroup(group, dir);
  21241. container.addControl(dir.name, group);
  21242. group.updateValueAndValidity({ emitEvent: false });
  21243. });
  21244. };
  21245. NgForm.prototype.removeControlGroup = function (dir) {
  21246. var _this = this;
  21247. async_1.PromiseWrapper.scheduleMicrotask(function () {
  21248. var container = _this._findContainer(dir.path);
  21249. if (lang_1.isPresent(container)) {
  21250. container.removeControl(dir.name);
  21251. container.updateValueAndValidity({ emitEvent: false });
  21252. }
  21253. });
  21254. };
  21255. NgForm.prototype.getControlGroup = function (dir) {
  21256. return this.form.find(dir.path);
  21257. };
  21258. NgForm.prototype.updateModel = function (dir, value) {
  21259. var _this = this;
  21260. async_1.PromiseWrapper.scheduleMicrotask(function () {
  21261. var ctrl = _this.form.find(dir.path);
  21262. ctrl.updateValue(value);
  21263. });
  21264. };
  21265. NgForm.prototype.onSubmit = function () {
  21266. async_1.ObservableWrapper.callEmit(this.ngSubmit, null);
  21267. return false;
  21268. };
  21269. /** @internal */
  21270. NgForm.prototype._findContainer = function (path) {
  21271. path.pop();
  21272. return collection_1.ListWrapper.isEmpty(path) ? this.form : this.form.find(path);
  21273. };
  21274. NgForm = __decorate([
  21275. core_1.Directive({
  21276. selector: 'form:not([ngNoForm]):not([ngFormModel]),ngForm,[ngForm]',
  21277. bindings: [formDirectiveProvider],
  21278. host: {
  21279. '(submit)': 'onSubmit()',
  21280. },
  21281. outputs: ['ngSubmit'],
  21282. exportAs: 'ngForm'
  21283. }),
  21284. __param(0, core_1.Optional()),
  21285. __param(0, core_1.Self()),
  21286. __param(0, core_1.Inject(validators_1.NG_VALIDATORS)),
  21287. __param(1, core_1.Optional()),
  21288. __param(1, core_1.Self()),
  21289. __param(1, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)),
  21290. __metadata('design:paramtypes', [Array, Array])
  21291. ], NgForm);
  21292. return NgForm;
  21293. })(control_container_1.ControlContainer);
  21294. exports.NgForm = NgForm;
  21295. /***/ },
  21296. /* 142 */
  21297. /***/ function(module, exports, __webpack_require__) {
  21298. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  21299. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  21300. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21301. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  21302. return c > 3 && r && Object.defineProperty(target, key, r), r;
  21303. };
  21304. var __metadata = (this && this.__metadata) || function (k, v) {
  21305. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  21306. };
  21307. var __param = (this && this.__param) || function (paramIndex, decorator) {
  21308. return function (target, key) { decorator(target, key, paramIndex); }
  21309. };
  21310. var core_1 = __webpack_require__(2);
  21311. var ng_control_1 = __webpack_require__(128);
  21312. var lang_1 = __webpack_require__(5);
  21313. /**
  21314. * Directive automatically applied to Angular forms that sets CSS classes
  21315. * based on control status (valid/invalid/dirty/etc).
  21316. */
  21317. var NgControlStatus = (function () {
  21318. function NgControlStatus(cd) {
  21319. this._cd = cd;
  21320. }
  21321. Object.defineProperty(NgControlStatus.prototype, "ngClassUntouched", {
  21322. get: function () {
  21323. return lang_1.isPresent(this._cd.control) ? this._cd.control.untouched : false;
  21324. },
  21325. enumerable: true,
  21326. configurable: true
  21327. });
  21328. Object.defineProperty(NgControlStatus.prototype, "ngClassTouched", {
  21329. get: function () {
  21330. return lang_1.isPresent(this._cd.control) ? this._cd.control.touched : false;
  21331. },
  21332. enumerable: true,
  21333. configurable: true
  21334. });
  21335. Object.defineProperty(NgControlStatus.prototype, "ngClassPristine", {
  21336. get: function () {
  21337. return lang_1.isPresent(this._cd.control) ? this._cd.control.pristine : false;
  21338. },
  21339. enumerable: true,
  21340. configurable: true
  21341. });
  21342. Object.defineProperty(NgControlStatus.prototype, "ngClassDirty", {
  21343. get: function () {
  21344. return lang_1.isPresent(this._cd.control) ? this._cd.control.dirty : false;
  21345. },
  21346. enumerable: true,
  21347. configurable: true
  21348. });
  21349. Object.defineProperty(NgControlStatus.prototype, "ngClassValid", {
  21350. get: function () {
  21351. return lang_1.isPresent(this._cd.control) ? this._cd.control.valid : false;
  21352. },
  21353. enumerable: true,
  21354. configurable: true
  21355. });
  21356. Object.defineProperty(NgControlStatus.prototype, "ngClassInvalid", {
  21357. get: function () {
  21358. return lang_1.isPresent(this._cd.control) ? !this._cd.control.valid : false;
  21359. },
  21360. enumerable: true,
  21361. configurable: true
  21362. });
  21363. NgControlStatus = __decorate([
  21364. core_1.Directive({
  21365. selector: '[ngControl],[ngModel],[ngFormControl]',
  21366. host: {
  21367. '[class.ng-untouched]': 'ngClassUntouched',
  21368. '[class.ng-touched]': 'ngClassTouched',
  21369. '[class.ng-pristine]': 'ngClassPristine',
  21370. '[class.ng-dirty]': 'ngClassDirty',
  21371. '[class.ng-valid]': 'ngClassValid',
  21372. '[class.ng-invalid]': 'ngClassInvalid'
  21373. }
  21374. }),
  21375. __param(0, core_1.Self()),
  21376. __metadata('design:paramtypes', [ng_control_1.NgControl])
  21377. ], NgControlStatus);
  21378. return NgControlStatus;
  21379. })();
  21380. exports.NgControlStatus = NgControlStatus;
  21381. /***/ },
  21382. /* 143 */
  21383. /***/ function(module, exports, __webpack_require__) {
  21384. var lang_1 = __webpack_require__(5);
  21385. var ng_control_name_1 = __webpack_require__(127);
  21386. var ng_form_control_1 = __webpack_require__(137);
  21387. var ng_model_1 = __webpack_require__(138);
  21388. var ng_control_group_1 = __webpack_require__(139);
  21389. var ng_form_model_1 = __webpack_require__(140);
  21390. var ng_form_1 = __webpack_require__(141);
  21391. var default_value_accessor_1 = __webpack_require__(132);
  21392. var checkbox_value_accessor_1 = __webpack_require__(134);
  21393. var number_value_accessor_1 = __webpack_require__(133);
  21394. var ng_control_status_1 = __webpack_require__(142);
  21395. var select_control_value_accessor_1 = __webpack_require__(135);
  21396. var validators_1 = __webpack_require__(144);
  21397. var ng_control_name_2 = __webpack_require__(127);
  21398. exports.NgControlName = ng_control_name_2.NgControlName;
  21399. var ng_form_control_2 = __webpack_require__(137);
  21400. exports.NgFormControl = ng_form_control_2.NgFormControl;
  21401. var ng_model_2 = __webpack_require__(138);
  21402. exports.NgModel = ng_model_2.NgModel;
  21403. var ng_control_group_2 = __webpack_require__(139);
  21404. exports.NgControlGroup = ng_control_group_2.NgControlGroup;
  21405. var ng_form_model_2 = __webpack_require__(140);
  21406. exports.NgFormModel = ng_form_model_2.NgFormModel;
  21407. var ng_form_2 = __webpack_require__(141);
  21408. exports.NgForm = ng_form_2.NgForm;
  21409. var default_value_accessor_2 = __webpack_require__(132);
  21410. exports.DefaultValueAccessor = default_value_accessor_2.DefaultValueAccessor;
  21411. var checkbox_value_accessor_2 = __webpack_require__(134);
  21412. exports.CheckboxControlValueAccessor = checkbox_value_accessor_2.CheckboxControlValueAccessor;
  21413. var number_value_accessor_2 = __webpack_require__(133);
  21414. exports.NumberValueAccessor = number_value_accessor_2.NumberValueAccessor;
  21415. var ng_control_status_2 = __webpack_require__(142);
  21416. exports.NgControlStatus = ng_control_status_2.NgControlStatus;
  21417. var select_control_value_accessor_2 = __webpack_require__(135);
  21418. exports.SelectControlValueAccessor = select_control_value_accessor_2.SelectControlValueAccessor;
  21419. exports.NgSelectOption = select_control_value_accessor_2.NgSelectOption;
  21420. var validators_2 = __webpack_require__(144);
  21421. exports.RequiredValidator = validators_2.RequiredValidator;
  21422. exports.MinLengthValidator = validators_2.MinLengthValidator;
  21423. exports.MaxLengthValidator = validators_2.MaxLengthValidator;
  21424. var ng_control_1 = __webpack_require__(128);
  21425. exports.NgControl = ng_control_1.NgControl;
  21426. /**
  21427. *
  21428. * A list of all the form directives used as part of a `@View` annotation.
  21429. *
  21430. * This is a shorthand for importing them each individually.
  21431. *
  21432. * ### Example
  21433. *
  21434. * ```typescript
  21435. * @Component({
  21436. * selector: 'my-app',
  21437. * directives: [FORM_DIRECTIVES]
  21438. * })
  21439. * class MyApp {}
  21440. * ```
  21441. */
  21442. exports.FORM_DIRECTIVES = lang_1.CONST_EXPR([
  21443. ng_control_name_1.NgControlName,
  21444. ng_control_group_1.NgControlGroup,
  21445. ng_form_control_1.NgFormControl,
  21446. ng_model_1.NgModel,
  21447. ng_form_model_1.NgFormModel,
  21448. ng_form_1.NgForm,
  21449. select_control_value_accessor_1.NgSelectOption,
  21450. default_value_accessor_1.DefaultValueAccessor,
  21451. number_value_accessor_1.NumberValueAccessor,
  21452. checkbox_value_accessor_1.CheckboxControlValueAccessor,
  21453. select_control_value_accessor_1.SelectControlValueAccessor,
  21454. ng_control_status_1.NgControlStatus,
  21455. validators_1.RequiredValidator,
  21456. validators_1.MinLengthValidator,
  21457. validators_1.MaxLengthValidator
  21458. ]);
  21459. /***/ },
  21460. /* 144 */
  21461. /***/ function(module, exports, __webpack_require__) {
  21462. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  21463. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  21464. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21465. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  21466. return c > 3 && r && Object.defineProperty(target, key, r), r;
  21467. };
  21468. var __metadata = (this && this.__metadata) || function (k, v) {
  21469. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  21470. };
  21471. var __param = (this && this.__param) || function (paramIndex, decorator) {
  21472. return function (target, key) { decorator(target, key, paramIndex); }
  21473. };
  21474. var core_1 = __webpack_require__(2);
  21475. var lang_1 = __webpack_require__(5);
  21476. var validators_1 = __webpack_require__(131);
  21477. var lang_2 = __webpack_require__(5);
  21478. var REQUIRED_VALIDATOR = lang_1.CONST_EXPR(new core_1.Provider(validators_1.NG_VALIDATORS, { useValue: validators_1.Validators.required, multi: true }));
  21479. /**
  21480. * A Directive that adds the `required` validator to any controls marked with the
  21481. * `required` attribute, via the {@link NG_VALIDATORS} binding.
  21482. *
  21483. * ### Example
  21484. *
  21485. * ```
  21486. * <input ngControl="fullName" required>
  21487. * ```
  21488. */
  21489. var RequiredValidator = (function () {
  21490. function RequiredValidator() {
  21491. }
  21492. RequiredValidator = __decorate([
  21493. core_1.Directive({
  21494. selector: '[required][ngControl],[required][ngFormControl],[required][ngModel]',
  21495. providers: [REQUIRED_VALIDATOR]
  21496. }),
  21497. __metadata('design:paramtypes', [])
  21498. ], RequiredValidator);
  21499. return RequiredValidator;
  21500. })();
  21501. exports.RequiredValidator = RequiredValidator;
  21502. /**
  21503. * Provivder which adds {@link MinLengthValidator} to {@link NG_VALIDATORS}.
  21504. *
  21505. * ## Example:
  21506. *
  21507. * {@example common/forms/ts/validators/validators.ts region='min'}
  21508. */
  21509. var MIN_LENGTH_VALIDATOR = lang_1.CONST_EXPR(new core_1.Provider(validators_1.NG_VALIDATORS, { useExisting: core_1.forwardRef(function () { return MinLengthValidator; }), multi: true }));
  21510. /**
  21511. * A directive which installs the {@link MinLengthValidator} for any `ngControl`,
  21512. * `ngFormControl`, or control with `ngModel` that also has a `minlength` attribute.
  21513. */
  21514. var MinLengthValidator = (function () {
  21515. function MinLengthValidator(minLength) {
  21516. this._validator = validators_1.Validators.minLength(lang_2.NumberWrapper.parseInt(minLength, 10));
  21517. }
  21518. MinLengthValidator.prototype.validate = function (c) { return this._validator(c); };
  21519. MinLengthValidator = __decorate([
  21520. core_1.Directive({
  21521. selector: '[minlength][ngControl],[minlength][ngFormControl],[minlength][ngModel]',
  21522. providers: [MIN_LENGTH_VALIDATOR]
  21523. }),
  21524. __param(0, core_1.Attribute("minlength")),
  21525. __metadata('design:paramtypes', [String])
  21526. ], MinLengthValidator);
  21527. return MinLengthValidator;
  21528. })();
  21529. exports.MinLengthValidator = MinLengthValidator;
  21530. /**
  21531. * Provider which adds {@link MaxLengthValidator} to {@link NG_VALIDATORS}.
  21532. *
  21533. * ## Example:
  21534. *
  21535. * {@example common/forms/ts/validators/validators.ts region='max'}
  21536. */
  21537. var MAX_LENGTH_VALIDATOR = lang_1.CONST_EXPR(new core_1.Provider(validators_1.NG_VALIDATORS, { useExisting: core_1.forwardRef(function () { return MaxLengthValidator; }), multi: true }));
  21538. /**
  21539. * A directive which installs the {@link MaxLengthValidator} for any `ngControl, `ngFormControl`,
  21540. * or control with `ngModel` that also has a `maxlength` attribute.
  21541. */
  21542. var MaxLengthValidator = (function () {
  21543. function MaxLengthValidator(maxLength) {
  21544. this._validator = validators_1.Validators.maxLength(lang_2.NumberWrapper.parseInt(maxLength, 10));
  21545. }
  21546. MaxLengthValidator.prototype.validate = function (c) { return this._validator(c); };
  21547. MaxLengthValidator = __decorate([
  21548. core_1.Directive({
  21549. selector: '[maxlength][ngControl],[maxlength][ngFormControl],[maxlength][ngModel]',
  21550. providers: [MAX_LENGTH_VALIDATOR]
  21551. }),
  21552. __param(0, core_1.Attribute("maxlength")),
  21553. __metadata('design:paramtypes', [String])
  21554. ], MaxLengthValidator);
  21555. return MaxLengthValidator;
  21556. })();
  21557. exports.MaxLengthValidator = MaxLengthValidator;
  21558. /***/ },
  21559. /* 145 */
  21560. /***/ function(module, exports, __webpack_require__) {
  21561. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  21562. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  21563. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21564. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  21565. return c > 3 && r && Object.defineProperty(target, key, r), r;
  21566. };
  21567. var __metadata = (this && this.__metadata) || function (k, v) {
  21568. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  21569. };
  21570. var core_1 = __webpack_require__(2);
  21571. var collection_1 = __webpack_require__(12);
  21572. var lang_1 = __webpack_require__(5);
  21573. var modelModule = __webpack_require__(124);
  21574. /**
  21575. * Creates a form object from a user-specified configuration.
  21576. *
  21577. * ### Example ([live demo](http://plnkr.co/edit/ENgZo8EuIECZNensZCVr?p=preview))
  21578. *
  21579. * ```typescript
  21580. * @Component({
  21581. * selector: 'my-app',
  21582. * viewBindings: [FORM_BINDINGS]
  21583. * template: `
  21584. * <form [ngFormModel]="loginForm">
  21585. * <p>Login <input ngControl="login"></p>
  21586. * <div ngControlGroup="passwordRetry">
  21587. * <p>Password <input type="password" ngControl="password"></p>
  21588. * <p>Confirm password <input type="password" ngControl="passwordConfirmation"></p>
  21589. * </div>
  21590. * </form>
  21591. * <h3>Form value:</h3>
  21592. * <pre>{{value}}</pre>
  21593. * `,
  21594. * directives: [FORM_DIRECTIVES]
  21595. * })
  21596. * export class App {
  21597. * loginForm: ControlGroup;
  21598. *
  21599. * constructor(builder: FormBuilder) {
  21600. * this.loginForm = builder.group({
  21601. * login: ["", Validators.required],
  21602. * passwordRetry: builder.group({
  21603. * password: ["", Validators.required],
  21604. * passwordConfirmation: ["", Validators.required, asyncValidator]
  21605. * })
  21606. * });
  21607. * }
  21608. *
  21609. * get value(): string {
  21610. * return JSON.stringify(this.loginForm.value, null, 2);
  21611. * }
  21612. * }
  21613. * ```
  21614. */
  21615. var FormBuilder = (function () {
  21616. function FormBuilder() {
  21617. }
  21618. /**
  21619. * Construct a new {@link ControlGroup} with the given map of configuration.
  21620. * Valid keys for the `extra` parameter map are `optionals` and `validator`.
  21621. *
  21622. * See the {@link ControlGroup} constructor for more details.
  21623. */
  21624. FormBuilder.prototype.group = function (controlsConfig, extra) {
  21625. if (extra === void 0) { extra = null; }
  21626. var controls = this._reduceControls(controlsConfig);
  21627. var optionals = lang_1.isPresent(extra) ? collection_1.StringMapWrapper.get(extra, "optionals") : null;
  21628. var validator = lang_1.isPresent(extra) ? collection_1.StringMapWrapper.get(extra, "validator") : null;
  21629. var asyncValidator = lang_1.isPresent(extra) ? collection_1.StringMapWrapper.get(extra, "asyncValidator") : null;
  21630. return new modelModule.ControlGroup(controls, optionals, validator, asyncValidator);
  21631. };
  21632. /**
  21633. * Construct a new {@link Control} with the given `value`,`validator`, and `asyncValidator`.
  21634. */
  21635. FormBuilder.prototype.control = function (value, validator, asyncValidator) {
  21636. if (validator === void 0) { validator = null; }
  21637. if (asyncValidator === void 0) { asyncValidator = null; }
  21638. return new modelModule.Control(value, validator, asyncValidator);
  21639. };
  21640. /**
  21641. * Construct an array of {@link Control}s from the given `controlsConfig` array of
  21642. * configuration, with the given optional `validator` and `asyncValidator`.
  21643. */
  21644. FormBuilder.prototype.array = function (controlsConfig, validator, asyncValidator) {
  21645. var _this = this;
  21646. if (validator === void 0) { validator = null; }
  21647. if (asyncValidator === void 0) { asyncValidator = null; }
  21648. var controls = controlsConfig.map(function (c) { return _this._createControl(c); });
  21649. return new modelModule.ControlArray(controls, validator, asyncValidator);
  21650. };
  21651. /** @internal */
  21652. FormBuilder.prototype._reduceControls = function (controlsConfig) {
  21653. var _this = this;
  21654. var controls = {};
  21655. collection_1.StringMapWrapper.forEach(controlsConfig, function (controlConfig, controlName) {
  21656. controls[controlName] = _this._createControl(controlConfig);
  21657. });
  21658. return controls;
  21659. };
  21660. /** @internal */
  21661. FormBuilder.prototype._createControl = function (controlConfig) {
  21662. if (controlConfig instanceof modelModule.Control ||
  21663. controlConfig instanceof modelModule.ControlGroup ||
  21664. controlConfig instanceof modelModule.ControlArray) {
  21665. return controlConfig;
  21666. }
  21667. else if (lang_1.isArray(controlConfig)) {
  21668. var value = controlConfig[0];
  21669. var validator = controlConfig.length > 1 ? controlConfig[1] : null;
  21670. var asyncValidator = controlConfig.length > 2 ? controlConfig[2] : null;
  21671. return this.control(value, validator, asyncValidator);
  21672. }
  21673. else {
  21674. return this.control(controlConfig);
  21675. }
  21676. };
  21677. FormBuilder = __decorate([
  21678. core_1.Injectable(),
  21679. __metadata('design:paramtypes', [])
  21680. ], FormBuilder);
  21681. return FormBuilder;
  21682. })();
  21683. exports.FormBuilder = FormBuilder;
  21684. /**
  21685. * Shorthand set of providers used for building Angular forms.
  21686. *
  21687. * ### Example
  21688. *
  21689. * ```typescript
  21690. * bootstrap(MyApp, [FORM_PROVIDERS]);
  21691. * ```
  21692. */
  21693. exports.FORM_PROVIDERS = lang_1.CONST_EXPR([FormBuilder]);
  21694. /**
  21695. * See {@link FORM_PROVIDERS} instead.
  21696. *
  21697. * @deprecated
  21698. */
  21699. exports.FORM_BINDINGS = exports.FORM_PROVIDERS;
  21700. /***/ },
  21701. /* 146 */
  21702. /***/ function(module, exports, __webpack_require__) {
  21703. var lang_1 = __webpack_require__(5);
  21704. var forms_1 = __webpack_require__(123);
  21705. var directives_1 = __webpack_require__(115);
  21706. /**
  21707. * A collection of Angular core directives that are likely to be used in each and every Angular
  21708. * application. This includes core directives (e.g., NgIf and NgFor), and forms directives (e.g.,
  21709. * NgModel).
  21710. *
  21711. * This collection can be used to quickly enumerate all the built-in directives in the `directives`
  21712. * property of the `@Component` or `@View` decorators.
  21713. *
  21714. * ### Example
  21715. *
  21716. * Instead of writing:
  21717. *
  21718. * ```typescript
  21719. * import {NgClass, NgIf, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault, NgModel, NgForm} from
  21720. * 'angular2/common';
  21721. * import {OtherDirective} from './myDirectives';
  21722. *
  21723. * @Component({
  21724. * selector: 'my-component',
  21725. * templateUrl: 'myComponent.html',
  21726. * directives: [NgClass, NgIf, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault, NgModel, NgForm,
  21727. * OtherDirective]
  21728. * })
  21729. * export class MyComponent {
  21730. * ...
  21731. * }
  21732. * ```
  21733. * one could import all the common directives at once:
  21734. *
  21735. * ```typescript
  21736. * import {COMMON_DIRECTIVES} from 'angular2/common';
  21737. * import {OtherDirective} from './myDirectives';
  21738. *
  21739. * @Component({
  21740. * selector: 'my-component',
  21741. * templateUrl: 'myComponent.html',
  21742. * directives: [COMMON_DIRECTIVES, OtherDirective]
  21743. * })
  21744. * export class MyComponent {
  21745. * ...
  21746. * }
  21747. * ```
  21748. */
  21749. exports.COMMON_DIRECTIVES = lang_1.CONST_EXPR([directives_1.CORE_DIRECTIVES, forms_1.FORM_DIRECTIVES]);
  21750. /***/ },
  21751. /* 147 */
  21752. /***/ function(module, exports, __webpack_require__) {
  21753. function __export(m) {
  21754. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  21755. }
  21756. /**
  21757. * @module
  21758. * @description
  21759. * Starting point to import all compiler APIs.
  21760. */
  21761. __export(__webpack_require__(148));
  21762. __export(__webpack_require__(149));
  21763. __export(__webpack_require__(150));
  21764. /***/ },
  21765. /* 148 */
  21766. /***/ function(module, exports, __webpack_require__) {
  21767. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  21768. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  21769. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21770. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  21771. return c > 3 && r && Object.defineProperty(target, key, r), r;
  21772. };
  21773. var __metadata = (this && this.__metadata) || function (k, v) {
  21774. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  21775. };
  21776. var __param = (this && this.__param) || function (paramIndex, decorator) {
  21777. return function (target, key) { decorator(target, key, paramIndex); }
  21778. };
  21779. var di_1 = __webpack_require__(6);
  21780. var lang_1 = __webpack_require__(5);
  21781. var application_tokens_1 = __webpack_require__(67);
  21782. var di_2 = __webpack_require__(6);
  21783. /**
  21784. * Create a {@link UrlResolver} with no package prefix.
  21785. */
  21786. function createWithoutPackagePrefix() {
  21787. return new UrlResolver();
  21788. }
  21789. exports.createWithoutPackagePrefix = createWithoutPackagePrefix;
  21790. /**
  21791. * A default provider for {@link PACKAGE_ROOT_URL} that maps to '/'.
  21792. */
  21793. exports.DEFAULT_PACKAGE_URL_PROVIDER = new di_2.Provider(application_tokens_1.PACKAGE_ROOT_URL, { useValue: "/" });
  21794. /**
  21795. * Used by the {@link Compiler} when resolving HTML and CSS template URLs.
  21796. *
  21797. * This class can be overridden by the application developer to create custom behavior.
  21798. *
  21799. * See {@link Compiler}
  21800. *
  21801. * ## Example
  21802. *
  21803. * {@example compiler/ts/url_resolver/url_resolver.ts region='url_resolver'}
  21804. */
  21805. var UrlResolver = (function () {
  21806. function UrlResolver(packagePrefix) {
  21807. if (packagePrefix === void 0) { packagePrefix = null; }
  21808. if (lang_1.isPresent(packagePrefix)) {
  21809. this._packagePrefix = lang_1.StringWrapper.stripRight(packagePrefix, "/") + "/";
  21810. }
  21811. }
  21812. /**
  21813. * Resolves the `url` given the `baseUrl`:
  21814. * - when the `url` is null, the `baseUrl` is returned,
  21815. * - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of
  21816. * `baseUrl` and `url`,
  21817. * - if `url` is absolute (it has a scheme: 'http://', 'https://' or start with '/'), the `url` is
  21818. * returned as is (ignoring the `baseUrl`)
  21819. *
  21820. * @param {string} baseUrl
  21821. * @param {string} url
  21822. * @returns {string} the resolved URL
  21823. */
  21824. UrlResolver.prototype.resolve = function (baseUrl, url) {
  21825. var resolvedUrl = url;
  21826. if (lang_1.isPresent(baseUrl) && baseUrl.length > 0) {
  21827. resolvedUrl = _resolveUrl(baseUrl, resolvedUrl);
  21828. }
  21829. if (lang_1.isPresent(this._packagePrefix) && getUrlScheme(resolvedUrl) == "package") {
  21830. resolvedUrl = resolvedUrl.replace("package:", this._packagePrefix);
  21831. }
  21832. return resolvedUrl;
  21833. };
  21834. UrlResolver = __decorate([
  21835. di_1.Injectable(),
  21836. __param(0, di_1.Inject(application_tokens_1.PACKAGE_ROOT_URL)),
  21837. __metadata('design:paramtypes', [String])
  21838. ], UrlResolver);
  21839. return UrlResolver;
  21840. })();
  21841. exports.UrlResolver = UrlResolver;
  21842. /**
  21843. * Extract the scheme of a URL.
  21844. */
  21845. function getUrlScheme(url) {
  21846. var match = _split(url);
  21847. return (match && match[_ComponentIndex.Scheme]) || "";
  21848. }
  21849. exports.getUrlScheme = getUrlScheme;
  21850. // The code below is adapted from Traceur:
  21851. // https://github.com/google/traceur-compiler/blob/9511c1dafa972bf0de1202a8a863bad02f0f95a8/src/runtime/url.js
  21852. /**
  21853. * Builds a URI string from already-encoded parts.
  21854. *
  21855. * No encoding is performed. Any component may be omitted as either null or
  21856. * undefined.
  21857. *
  21858. * @param {?string=} opt_scheme The scheme such as 'http'.
  21859. * @param {?string=} opt_userInfo The user name before the '@'.
  21860. * @param {?string=} opt_domain The domain such as 'www.google.com', already
  21861. * URI-encoded.
  21862. * @param {(string|null)=} opt_port The port number.
  21863. * @param {?string=} opt_path The path, already URI-encoded. If it is not
  21864. * empty, it must begin with a slash.
  21865. * @param {?string=} opt_queryData The URI-encoded query data.
  21866. * @param {?string=} opt_fragment The URI-encoded fragment identifier.
  21867. * @return {string} The fully combined URI.
  21868. */
  21869. function _buildFromEncodedParts(opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_queryData, opt_fragment) {
  21870. var out = [];
  21871. if (lang_1.isPresent(opt_scheme)) {
  21872. out.push(opt_scheme + ':');
  21873. }
  21874. if (lang_1.isPresent(opt_domain)) {
  21875. out.push('//');
  21876. if (lang_1.isPresent(opt_userInfo)) {
  21877. out.push(opt_userInfo + '@');
  21878. }
  21879. out.push(opt_domain);
  21880. if (lang_1.isPresent(opt_port)) {
  21881. out.push(':' + opt_port);
  21882. }
  21883. }
  21884. if (lang_1.isPresent(opt_path)) {
  21885. out.push(opt_path);
  21886. }
  21887. if (lang_1.isPresent(opt_queryData)) {
  21888. out.push('?' + opt_queryData);
  21889. }
  21890. if (lang_1.isPresent(opt_fragment)) {
  21891. out.push('#' + opt_fragment);
  21892. }
  21893. return out.join('');
  21894. }
  21895. /**
  21896. * A regular expression for breaking a URI into its component parts.
  21897. *
  21898. * {@link http://www.gbiv.com/protocols/uri/rfc/rfc3986.html#RFC2234} says
  21899. * As the "first-match-wins" algorithm is identical to the "greedy"
  21900. * disambiguation method used by POSIX regular expressions, it is natural and
  21901. * commonplace to use a regular expression for parsing the potential five
  21902. * components of a URI reference.
  21903. *
  21904. * The following line is the regular expression for breaking-down a
  21905. * well-formed URI reference into its components.
  21906. *
  21907. * <pre>
  21908. * ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
  21909. * 12 3 4 5 6 7 8 9
  21910. * </pre>
  21911. *
  21912. * The numbers in the second line above are only to assist readability; they
  21913. * indicate the reference points for each subexpression (i.e., each paired
  21914. * parenthesis). We refer to the value matched for subexpression <n> as $<n>.
  21915. * For example, matching the above expression to
  21916. * <pre>
  21917. * http://www.ics.uci.edu/pub/ietf/uri/#Related
  21918. * </pre>
  21919. * results in the following subexpression matches:
  21920. * <pre>
  21921. * $1 = http:
  21922. * $2 = http
  21923. * $3 = //www.ics.uci.edu
  21924. * $4 = www.ics.uci.edu
  21925. * $5 = /pub/ietf/uri/
  21926. * $6 = <undefined>
  21927. * $7 = <undefined>
  21928. * $8 = #Related
  21929. * $9 = Related
  21930. * </pre>
  21931. * where <undefined> indicates that the component is not present, as is the
  21932. * case for the query component in the above example. Therefore, we can
  21933. * determine the value of the five components as
  21934. * <pre>
  21935. * scheme = $2
  21936. * authority = $4
  21937. * path = $5
  21938. * query = $7
  21939. * fragment = $9
  21940. * </pre>
  21941. *
  21942. * The regular expression has been modified slightly to expose the
  21943. * userInfo, domain, and port separately from the authority.
  21944. * The modified version yields
  21945. * <pre>
  21946. * $1 = http scheme
  21947. * $2 = <undefined> userInfo -\
  21948. * $3 = www.ics.uci.edu domain | authority
  21949. * $4 = <undefined> port -/
  21950. * $5 = /pub/ietf/uri/ path
  21951. * $6 = <undefined> query without ?
  21952. * $7 = Related fragment without #
  21953. * </pre>
  21954. * @type {!RegExp}
  21955. * @internal
  21956. */
  21957. var _splitRe = lang_1.RegExpWrapper.create('^' +
  21958. '(?:' +
  21959. '([^:/?#.]+)' +
  21960. // used by other URL parts such as :,
  21961. // ?, /, #, and .
  21962. ':)?' +
  21963. '(?://' +
  21964. '(?:([^/?#]*)@)?' +
  21965. '([\\w\\d\\-\\u0100-\\uffff.%]*)' +
  21966. // digits, dashes, dots, percent
  21967. // escapes, and unicode characters.
  21968. '(?::([0-9]+))?' +
  21969. ')?' +
  21970. '([^?#]+)?' +
  21971. '(?:\\?([^#]*))?' +
  21972. '(?:#(.*))?' +
  21973. '$');
  21974. /**
  21975. * The index of each URI component in the return value of goog.uri.utils.split.
  21976. * @enum {number}
  21977. */
  21978. var _ComponentIndex;
  21979. (function (_ComponentIndex) {
  21980. _ComponentIndex[_ComponentIndex["Scheme"] = 1] = "Scheme";
  21981. _ComponentIndex[_ComponentIndex["UserInfo"] = 2] = "UserInfo";
  21982. _ComponentIndex[_ComponentIndex["Domain"] = 3] = "Domain";
  21983. _ComponentIndex[_ComponentIndex["Port"] = 4] = "Port";
  21984. _ComponentIndex[_ComponentIndex["Path"] = 5] = "Path";
  21985. _ComponentIndex[_ComponentIndex["QueryData"] = 6] = "QueryData";
  21986. _ComponentIndex[_ComponentIndex["Fragment"] = 7] = "Fragment";
  21987. })(_ComponentIndex || (_ComponentIndex = {}));
  21988. /**
  21989. * Splits a URI into its component parts.
  21990. *
  21991. * Each component can be accessed via the component indices; for example:
  21992. * <pre>
  21993. * goog.uri.utils.split(someStr)[goog.uri.utils.CompontentIndex.QUERY_DATA];
  21994. * </pre>
  21995. *
  21996. * @param {string} uri The URI string to examine.
  21997. * @return {!Array.<string|undefined>} Each component still URI-encoded.
  21998. * Each component that is present will contain the encoded value, whereas
  21999. * components that are not present will be undefined or empty, depending
  22000. * on the browser's regular expression implementation. Never null, since
  22001. * arbitrary strings may still look like path names.
  22002. */
  22003. function _split(uri) {
  22004. return lang_1.RegExpWrapper.firstMatch(_splitRe, uri);
  22005. }
  22006. /**
  22007. * Removes dot segments in given path component, as described in
  22008. * RFC 3986, section 5.2.4.
  22009. *
  22010. * @param {string} path A non-empty path component.
  22011. * @return {string} Path component with removed dot segments.
  22012. */
  22013. function _removeDotSegments(path) {
  22014. if (path == '/')
  22015. return '/';
  22016. var leadingSlash = path[0] == '/' ? '/' : '';
  22017. var trailingSlash = path[path.length - 1] === '/' ? '/' : '';
  22018. var segments = path.split('/');
  22019. var out = [];
  22020. var up = 0;
  22021. for (var pos = 0; pos < segments.length; pos++) {
  22022. var segment = segments[pos];
  22023. switch (segment) {
  22024. case '':
  22025. case '.':
  22026. break;
  22027. case '..':
  22028. if (out.length > 0) {
  22029. out.pop();
  22030. }
  22031. else {
  22032. up++;
  22033. }
  22034. break;
  22035. default:
  22036. out.push(segment);
  22037. }
  22038. }
  22039. if (leadingSlash == '') {
  22040. while (up-- > 0) {
  22041. out.unshift('..');
  22042. }
  22043. if (out.length === 0)
  22044. out.push('.');
  22045. }
  22046. return leadingSlash + out.join('/') + trailingSlash;
  22047. }
  22048. /**
  22049. * Takes an array of the parts from split and canonicalizes the path part
  22050. * and then joins all the parts.
  22051. * @param {Array.<string?>} parts
  22052. * @return {string}
  22053. */
  22054. function _joinAndCanonicalizePath(parts) {
  22055. var path = parts[_ComponentIndex.Path];
  22056. path = lang_1.isBlank(path) ? '' : _removeDotSegments(path);
  22057. parts[_ComponentIndex.Path] = path;
  22058. return _buildFromEncodedParts(parts[_ComponentIndex.Scheme], parts[_ComponentIndex.UserInfo], parts[_ComponentIndex.Domain], parts[_ComponentIndex.Port], path, parts[_ComponentIndex.QueryData], parts[_ComponentIndex.Fragment]);
  22059. }
  22060. /**
  22061. * Resolves a URL.
  22062. * @param {string} base The URL acting as the base URL.
  22063. * @param {string} to The URL to resolve.
  22064. * @return {string}
  22065. */
  22066. function _resolveUrl(base, url) {
  22067. var parts = _split(encodeURI(url));
  22068. var baseParts = _split(base);
  22069. if (lang_1.isPresent(parts[_ComponentIndex.Scheme])) {
  22070. return _joinAndCanonicalizePath(parts);
  22071. }
  22072. else {
  22073. parts[_ComponentIndex.Scheme] = baseParts[_ComponentIndex.Scheme];
  22074. }
  22075. for (var i = _ComponentIndex.Scheme; i <= _ComponentIndex.Port; i++) {
  22076. if (lang_1.isBlank(parts[i])) {
  22077. parts[i] = baseParts[i];
  22078. }
  22079. }
  22080. if (parts[_ComponentIndex.Path][0] == '/') {
  22081. return _joinAndCanonicalizePath(parts);
  22082. }
  22083. var path = baseParts[_ComponentIndex.Path];
  22084. if (lang_1.isBlank(path))
  22085. path = '/';
  22086. var index = path.lastIndexOf('/');
  22087. path = path.substring(0, index + 1) + parts[_ComponentIndex.Path];
  22088. parts[_ComponentIndex.Path] = path;
  22089. return _joinAndCanonicalizePath(parts);
  22090. }
  22091. /***/ },
  22092. /* 149 */
  22093. /***/ function(module, exports) {
  22094. // TODO: vsavkin rename it into TemplateLoader
  22095. /**
  22096. * An interface for retrieving documents by URL that the compiler uses
  22097. * to load templates.
  22098. */
  22099. var XHR = (function () {
  22100. function XHR() {
  22101. }
  22102. XHR.prototype.get = function (url) { return null; };
  22103. return XHR;
  22104. })();
  22105. exports.XHR = XHR;
  22106. /***/ },
  22107. /* 150 */
  22108. /***/ function(module, exports, __webpack_require__) {
  22109. function __export(m) {
  22110. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  22111. }
  22112. var runtime_compiler_1 = __webpack_require__(151);
  22113. var template_compiler_1 = __webpack_require__(152);
  22114. exports.TemplateCompiler = template_compiler_1.TemplateCompiler;
  22115. var directive_metadata_1 = __webpack_require__(153);
  22116. exports.CompileDirectiveMetadata = directive_metadata_1.CompileDirectiveMetadata;
  22117. exports.CompileTypeMetadata = directive_metadata_1.CompileTypeMetadata;
  22118. exports.CompileTemplateMetadata = directive_metadata_1.CompileTemplateMetadata;
  22119. var source_module_1 = __webpack_require__(156);
  22120. exports.SourceModule = source_module_1.SourceModule;
  22121. exports.SourceWithImports = source_module_1.SourceWithImports;
  22122. var platform_directives_and_pipes_1 = __webpack_require__(95);
  22123. exports.PLATFORM_DIRECTIVES = platform_directives_and_pipes_1.PLATFORM_DIRECTIVES;
  22124. exports.PLATFORM_PIPES = platform_directives_and_pipes_1.PLATFORM_PIPES;
  22125. __export(__webpack_require__(159));
  22126. var template_parser_1 = __webpack_require__(167);
  22127. exports.TEMPLATE_TRANSFORMS = template_parser_1.TEMPLATE_TRANSFORMS;
  22128. var lang_1 = __webpack_require__(5);
  22129. var di_1 = __webpack_require__(6);
  22130. var template_parser_2 = __webpack_require__(167);
  22131. var html_parser_1 = __webpack_require__(168);
  22132. var template_normalizer_1 = __webpack_require__(175);
  22133. var runtime_metadata_1 = __webpack_require__(176);
  22134. var change_detector_compiler_1 = __webpack_require__(157);
  22135. var style_compiler_1 = __webpack_require__(161);
  22136. var command_compiler_1 = __webpack_require__(166);
  22137. var template_compiler_2 = __webpack_require__(152);
  22138. var change_detection_1 = __webpack_require__(25);
  22139. var compiler_1 = __webpack_require__(70);
  22140. var runtime_compiler_2 = __webpack_require__(151);
  22141. var element_schema_registry_1 = __webpack_require__(173);
  22142. var dom_element_schema_registry_1 = __webpack_require__(177);
  22143. var url_resolver_1 = __webpack_require__(148);
  22144. var change_detection_2 = __webpack_require__(25);
  22145. function _createChangeDetectorGenConfig() {
  22146. return new change_detection_1.ChangeDetectorGenConfig(lang_1.assertionsEnabled(), false, true);
  22147. }
  22148. /**
  22149. * A set of providers that provide `RuntimeCompiler` and its dependencies to use for
  22150. * template compilation.
  22151. */
  22152. exports.COMPILER_PROVIDERS = lang_1.CONST_EXPR([
  22153. change_detection_2.Lexer,
  22154. change_detection_2.Parser,
  22155. html_parser_1.HtmlParser,
  22156. template_parser_2.TemplateParser,
  22157. template_normalizer_1.TemplateNormalizer,
  22158. runtime_metadata_1.RuntimeMetadataResolver,
  22159. url_resolver_1.DEFAULT_PACKAGE_URL_PROVIDER,
  22160. style_compiler_1.StyleCompiler,
  22161. command_compiler_1.CommandCompiler,
  22162. change_detector_compiler_1.ChangeDetectionCompiler,
  22163. new di_1.Provider(change_detection_1.ChangeDetectorGenConfig, { useFactory: _createChangeDetectorGenConfig, deps: [] }),
  22164. template_compiler_2.TemplateCompiler,
  22165. new di_1.Provider(runtime_compiler_2.RuntimeCompiler, { useClass: runtime_compiler_1.RuntimeCompiler_ }),
  22166. new di_1.Provider(compiler_1.Compiler, { useExisting: runtime_compiler_2.RuntimeCompiler }),
  22167. dom_element_schema_registry_1.DomElementSchemaRegistry,
  22168. new di_1.Provider(element_schema_registry_1.ElementSchemaRegistry, { useExisting: dom_element_schema_registry_1.DomElementSchemaRegistry }),
  22169. url_resolver_1.UrlResolver
  22170. ]);
  22171. /***/ },
  22172. /* 151 */
  22173. /***/ function(module, exports, __webpack_require__) {
  22174. var __extends = (this && this.__extends) || function (d, b) {
  22175. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  22176. function __() { this.constructor = d; }
  22177. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22178. };
  22179. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  22180. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  22181. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  22182. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22183. return c > 3 && r && Object.defineProperty(target, key, r), r;
  22184. };
  22185. var __metadata = (this && this.__metadata) || function (k, v) {
  22186. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  22187. };
  22188. var compiler_1 = __webpack_require__(70);
  22189. var proto_view_factory_1 = __webpack_require__(71);
  22190. var template_compiler_1 = __webpack_require__(152);
  22191. var di_1 = __webpack_require__(6);
  22192. var RuntimeCompiler = (function (_super) {
  22193. __extends(RuntimeCompiler, _super);
  22194. function RuntimeCompiler() {
  22195. _super.apply(this, arguments);
  22196. }
  22197. return RuntimeCompiler;
  22198. })(compiler_1.Compiler);
  22199. exports.RuntimeCompiler = RuntimeCompiler;
  22200. var RuntimeCompiler_ = (function (_super) {
  22201. __extends(RuntimeCompiler_, _super);
  22202. function RuntimeCompiler_(_protoViewFactory, _templateCompiler) {
  22203. _super.call(this, _protoViewFactory);
  22204. this._templateCompiler = _templateCompiler;
  22205. }
  22206. RuntimeCompiler_.prototype.compileInHost = function (componentType) {
  22207. var _this = this;
  22208. return this._templateCompiler.compileHostComponentRuntime(componentType)
  22209. .then(function (compiledHostTemplate) { return compiler_1.internalCreateProtoView(_this, compiledHostTemplate); });
  22210. };
  22211. RuntimeCompiler_.prototype.clearCache = function () {
  22212. _super.prototype.clearCache.call(this);
  22213. this._templateCompiler.clearCache();
  22214. };
  22215. RuntimeCompiler_ = __decorate([
  22216. di_1.Injectable(),
  22217. __metadata('design:paramtypes', [proto_view_factory_1.ProtoViewFactory, template_compiler_1.TemplateCompiler])
  22218. ], RuntimeCompiler_);
  22219. return RuntimeCompiler_;
  22220. })(compiler_1.Compiler_);
  22221. exports.RuntimeCompiler_ = RuntimeCompiler_;
  22222. /***/ },
  22223. /* 152 */
  22224. /***/ function(module, exports, __webpack_require__) {
  22225. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  22226. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  22227. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  22228. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22229. return c > 3 && r && Object.defineProperty(target, key, r), r;
  22230. };
  22231. var __metadata = (this && this.__metadata) || function (k, v) {
  22232. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  22233. };
  22234. var lang_1 = __webpack_require__(5);
  22235. var exceptions_1 = __webpack_require__(14);
  22236. var collection_1 = __webpack_require__(12);
  22237. var async_1 = __webpack_require__(60);
  22238. var template_commands_1 = __webpack_require__(96);
  22239. var directive_metadata_1 = __webpack_require__(153);
  22240. var di_1 = __webpack_require__(6);
  22241. var source_module_1 = __webpack_require__(156);
  22242. var change_detector_compiler_1 = __webpack_require__(157);
  22243. var style_compiler_1 = __webpack_require__(161);
  22244. var command_compiler_1 = __webpack_require__(166);
  22245. var template_parser_1 = __webpack_require__(167);
  22246. var template_normalizer_1 = __webpack_require__(175);
  22247. var runtime_metadata_1 = __webpack_require__(176);
  22248. var command_compiler_2 = __webpack_require__(166);
  22249. var util_1 = __webpack_require__(155);
  22250. /**
  22251. * An internal module of the Angular compiler that begins with component types,
  22252. * extracts templates, and eventually produces a compiled version of the component
  22253. * ready for linking into an application.
  22254. */
  22255. var TemplateCompiler = (function () {
  22256. function TemplateCompiler(_runtimeMetadataResolver, _templateNormalizer, _templateParser, _styleCompiler, _commandCompiler, _cdCompiler) {
  22257. this._runtimeMetadataResolver = _runtimeMetadataResolver;
  22258. this._templateNormalizer = _templateNormalizer;
  22259. this._templateParser = _templateParser;
  22260. this._styleCompiler = _styleCompiler;
  22261. this._commandCompiler = _commandCompiler;
  22262. this._cdCompiler = _cdCompiler;
  22263. this._hostCacheKeys = new Map();
  22264. this._compiledTemplateCache = new Map();
  22265. this._compiledTemplateDone = new Map();
  22266. this._nextTemplateId = 0;
  22267. }
  22268. TemplateCompiler.prototype.normalizeDirectiveMetadata = function (directive) {
  22269. if (!directive.isComponent) {
  22270. // For non components there is nothing to be normalized yet.
  22271. return async_1.PromiseWrapper.resolve(directive);
  22272. }
  22273. return this._templateNormalizer.normalizeTemplate(directive.type, directive.template)
  22274. .then(function (normalizedTemplate) { return new directive_metadata_1.CompileDirectiveMetadata({
  22275. type: directive.type,
  22276. isComponent: directive.isComponent,
  22277. dynamicLoadable: directive.dynamicLoadable,
  22278. selector: directive.selector,
  22279. exportAs: directive.exportAs,
  22280. changeDetection: directive.changeDetection,
  22281. inputs: directive.inputs,
  22282. outputs: directive.outputs,
  22283. hostListeners: directive.hostListeners,
  22284. hostProperties: directive.hostProperties,
  22285. hostAttributes: directive.hostAttributes,
  22286. lifecycleHooks: directive.lifecycleHooks,
  22287. template: normalizedTemplate
  22288. }); });
  22289. };
  22290. TemplateCompiler.prototype.compileHostComponentRuntime = function (type) {
  22291. var hostCacheKey = this._hostCacheKeys.get(type);
  22292. if (lang_1.isBlank(hostCacheKey)) {
  22293. hostCacheKey = new Object();
  22294. this._hostCacheKeys.set(type, hostCacheKey);
  22295. var compMeta = this._runtimeMetadataResolver.getMetadata(type);
  22296. assertComponent(compMeta);
  22297. var hostMeta = directive_metadata_1.createHostComponentMeta(compMeta.type, compMeta.selector);
  22298. this._compileComponentRuntime(hostCacheKey, hostMeta, [compMeta], new Set());
  22299. }
  22300. return this._compiledTemplateDone.get(hostCacheKey)
  22301. .then(function (compiledTemplate) { return new template_commands_1.CompiledHostTemplate(compiledTemplate); });
  22302. };
  22303. TemplateCompiler.prototype.clearCache = function () {
  22304. this._hostCacheKeys.clear();
  22305. this._styleCompiler.clearCache();
  22306. this._compiledTemplateCache.clear();
  22307. this._compiledTemplateDone.clear();
  22308. };
  22309. TemplateCompiler.prototype._compileComponentRuntime = function (cacheKey, compMeta, viewDirectives, compilingComponentCacheKeys) {
  22310. var _this = this;
  22311. var uniqViewDirectives = removeDuplicates(viewDirectives);
  22312. var compiledTemplate = this._compiledTemplateCache.get(cacheKey);
  22313. var done = this._compiledTemplateDone.get(cacheKey);
  22314. if (lang_1.isBlank(compiledTemplate)) {
  22315. var styles = [];
  22316. var changeDetectorFactory;
  22317. var commands = [];
  22318. var templateId = lang_1.stringify(compMeta.type.runtime) + "Template" + this._nextTemplateId++;
  22319. compiledTemplate = new template_commands_1.CompiledComponentTemplate(templateId, function (dispatcher) { return changeDetectorFactory(dispatcher); }, commands, styles);
  22320. this._compiledTemplateCache.set(cacheKey, compiledTemplate);
  22321. compilingComponentCacheKeys.add(cacheKey);
  22322. done = async_1.PromiseWrapper
  22323. .all([this._styleCompiler.compileComponentRuntime(compMeta.template)].concat(uniqViewDirectives.map(function (dirMeta) { return _this.normalizeDirectiveMetadata(dirMeta); })))
  22324. .then(function (stylesAndNormalizedViewDirMetas) {
  22325. var childPromises = [];
  22326. var normalizedViewDirMetas = stylesAndNormalizedViewDirMetas.slice(1);
  22327. var parsedTemplate = _this._templateParser.parse(compMeta.template.template, normalizedViewDirMetas, compMeta.type.name);
  22328. var changeDetectorFactories = _this._cdCompiler.compileComponentRuntime(compMeta.type, compMeta.changeDetection, parsedTemplate);
  22329. changeDetectorFactory = changeDetectorFactories[0];
  22330. var tmpStyles = stylesAndNormalizedViewDirMetas[0];
  22331. tmpStyles.forEach(function (style) { return styles.push(style); });
  22332. var tmpCommands = _this._compileCommandsRuntime(compMeta, parsedTemplate, changeDetectorFactories, compilingComponentCacheKeys, childPromises);
  22333. tmpCommands.forEach(function (cmd) { return commands.push(cmd); });
  22334. return async_1.PromiseWrapper.all(childPromises);
  22335. })
  22336. .then(function (_) {
  22337. collection_1.SetWrapper.delete(compilingComponentCacheKeys, cacheKey);
  22338. return compiledTemplate;
  22339. });
  22340. this._compiledTemplateDone.set(cacheKey, done);
  22341. }
  22342. return compiledTemplate;
  22343. };
  22344. TemplateCompiler.prototype._compileCommandsRuntime = function (compMeta, parsedTemplate, changeDetectorFactories, compilingComponentCacheKeys, childPromises) {
  22345. var _this = this;
  22346. var cmds = this._commandCompiler.compileComponentRuntime(compMeta, parsedTemplate, changeDetectorFactories, function (childComponentDir) {
  22347. var childCacheKey = childComponentDir.type.runtime;
  22348. var childViewDirectives = _this._runtimeMetadataResolver.getViewDirectivesMetadata(childComponentDir.type.runtime);
  22349. var childIsRecursive = collection_1.SetWrapper.has(compilingComponentCacheKeys, childCacheKey);
  22350. var childTemplate = _this._compileComponentRuntime(childCacheKey, childComponentDir, childViewDirectives, compilingComponentCacheKeys);
  22351. if (!childIsRecursive) {
  22352. // Only wait for a child if it is not a cycle
  22353. childPromises.push(_this._compiledTemplateDone.get(childCacheKey));
  22354. }
  22355. return function () { return childTemplate; };
  22356. });
  22357. cmds.forEach(function (cmd) {
  22358. if (cmd instanceof template_commands_1.BeginComponentCmd) {
  22359. cmd.templateGetter();
  22360. }
  22361. });
  22362. return cmds;
  22363. };
  22364. TemplateCompiler.prototype.compileTemplatesCodeGen = function (components) {
  22365. var _this = this;
  22366. if (components.length === 0) {
  22367. throw new exceptions_1.BaseException('No components given');
  22368. }
  22369. var declarations = [];
  22370. var templateArguments = [];
  22371. var componentMetas = [];
  22372. components.forEach(function (componentWithDirs) {
  22373. var compMeta = componentWithDirs.component;
  22374. assertComponent(compMeta);
  22375. componentMetas.push(compMeta);
  22376. _this._processTemplateCodeGen(compMeta, componentWithDirs.directives, declarations, templateArguments);
  22377. if (compMeta.dynamicLoadable) {
  22378. var hostMeta = directive_metadata_1.createHostComponentMeta(compMeta.type, compMeta.selector);
  22379. componentMetas.push(hostMeta);
  22380. _this._processTemplateCodeGen(hostMeta, [compMeta], declarations, templateArguments);
  22381. }
  22382. });
  22383. collection_1.ListWrapper.forEachWithIndex(componentMetas, function (compMeta, index) {
  22384. var templateId = compMeta.type.moduleUrl + "|" + compMeta.type.name;
  22385. var constructionKeyword = lang_1.IS_DART ? 'const' : 'new';
  22386. var compiledTemplateExpr = constructionKeyword + " " + command_compiler_2.TEMPLATE_COMMANDS_MODULE_REF + "CompiledComponentTemplate('" + templateId + "'," + templateArguments[index].join(',') + ")";
  22387. var variableValueExpr;
  22388. if (compMeta.type.isHost) {
  22389. variableValueExpr =
  22390. constructionKeyword + " " + command_compiler_2.TEMPLATE_COMMANDS_MODULE_REF + "CompiledHostTemplate(" + compiledTemplateExpr + ")";
  22391. }
  22392. else {
  22393. variableValueExpr = compiledTemplateExpr;
  22394. }
  22395. var varName = templateVariableName(compMeta.type);
  22396. declarations.push("" + util_1.codeGenExportVariable(varName) + variableValueExpr + ";");
  22397. declarations.push(util_1.codeGenValueFn([], varName, templateGetterName(compMeta.type)) + ";");
  22398. });
  22399. var moduleUrl = components[0].component.type.moduleUrl;
  22400. return new source_module_1.SourceModule("" + templateModuleUrl(moduleUrl), declarations.join('\n'));
  22401. };
  22402. TemplateCompiler.prototype.compileStylesheetCodeGen = function (stylesheetUrl, cssText) {
  22403. return this._styleCompiler.compileStylesheetCodeGen(stylesheetUrl, cssText);
  22404. };
  22405. TemplateCompiler.prototype._processTemplateCodeGen = function (compMeta, directives, targetDeclarations, targetTemplateArguments) {
  22406. var uniqueDirectives = removeDuplicates(directives);
  22407. var styleExpr = this._styleCompiler.compileComponentCodeGen(compMeta.template);
  22408. var parsedTemplate = this._templateParser.parse(compMeta.template.template, uniqueDirectives, compMeta.type.name);
  22409. var changeDetectorsExprs = this._cdCompiler.compileComponentCodeGen(compMeta.type, compMeta.changeDetection, parsedTemplate);
  22410. var commandsExpr = this._commandCompiler.compileComponentCodeGen(compMeta, parsedTemplate, changeDetectorsExprs.expressions, codeGenComponentTemplateFactory);
  22411. addAll(styleExpr.declarations, targetDeclarations);
  22412. addAll(changeDetectorsExprs.declarations, targetDeclarations);
  22413. addAll(commandsExpr.declarations, targetDeclarations);
  22414. targetTemplateArguments.push([changeDetectorsExprs.expressions[0], commandsExpr.expression, styleExpr.expression]);
  22415. };
  22416. TemplateCompiler = __decorate([
  22417. di_1.Injectable(),
  22418. __metadata('design:paramtypes', [runtime_metadata_1.RuntimeMetadataResolver, template_normalizer_1.TemplateNormalizer, template_parser_1.TemplateParser, style_compiler_1.StyleCompiler, command_compiler_1.CommandCompiler, change_detector_compiler_1.ChangeDetectionCompiler])
  22419. ], TemplateCompiler);
  22420. return TemplateCompiler;
  22421. })();
  22422. exports.TemplateCompiler = TemplateCompiler;
  22423. var NormalizedComponentWithViewDirectives = (function () {
  22424. function NormalizedComponentWithViewDirectives(component, directives) {
  22425. this.component = component;
  22426. this.directives = directives;
  22427. }
  22428. return NormalizedComponentWithViewDirectives;
  22429. })();
  22430. exports.NormalizedComponentWithViewDirectives = NormalizedComponentWithViewDirectives;
  22431. function assertComponent(meta) {
  22432. if (!meta.isComponent) {
  22433. throw new exceptions_1.BaseException("Could not compile '" + meta.type.name + "' because it is not a component.");
  22434. }
  22435. }
  22436. function templateVariableName(type) {
  22437. return type.name + "Template";
  22438. }
  22439. function templateGetterName(type) {
  22440. return templateVariableName(type) + "Getter";
  22441. }
  22442. function templateModuleUrl(moduleUrl) {
  22443. var urlWithoutSuffix = moduleUrl.substring(0, moduleUrl.length - util_1.MODULE_SUFFIX.length);
  22444. return urlWithoutSuffix + ".template" + util_1.MODULE_SUFFIX;
  22445. }
  22446. function addAll(source, target) {
  22447. for (var i = 0; i < source.length; i++) {
  22448. target.push(source[i]);
  22449. }
  22450. }
  22451. function codeGenComponentTemplateFactory(nestedCompType) {
  22452. return "" + source_module_1.moduleRef(templateModuleUrl(nestedCompType.type.moduleUrl)) + templateGetterName(nestedCompType.type);
  22453. }
  22454. function removeDuplicates(items) {
  22455. var res = [];
  22456. items.forEach(function (item) {
  22457. var hasMatch = res.filter(function (r) { return r.type.name == item.type.name && r.type.moduleUrl == item.type.moduleUrl &&
  22458. r.type.runtime == item.type.runtime; })
  22459. .length > 0;
  22460. if (!hasMatch) {
  22461. res.push(item);
  22462. }
  22463. });
  22464. return res;
  22465. }
  22466. /***/ },
  22467. /* 153 */
  22468. /***/ function(module, exports, __webpack_require__) {
  22469. var lang_1 = __webpack_require__(5);
  22470. var collection_1 = __webpack_require__(12);
  22471. var change_detection_1 = __webpack_require__(25);
  22472. var view_1 = __webpack_require__(56);
  22473. var selector_1 = __webpack_require__(154);
  22474. var util_1 = __webpack_require__(155);
  22475. var interfaces_1 = __webpack_require__(89);
  22476. // group 1: "property" from "[property]"
  22477. // group 2: "event" from "(event)"
  22478. var HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))$/g;
  22479. /**
  22480. * Metadata regarding compilation of a type.
  22481. */
  22482. var CompileTypeMetadata = (function () {
  22483. function CompileTypeMetadata(_a) {
  22484. var _b = _a === void 0 ? {} : _a, runtime = _b.runtime, name = _b.name, moduleUrl = _b.moduleUrl, isHost = _b.isHost;
  22485. this.runtime = runtime;
  22486. this.name = name;
  22487. this.moduleUrl = moduleUrl;
  22488. this.isHost = lang_1.normalizeBool(isHost);
  22489. }
  22490. CompileTypeMetadata.fromJson = function (data) {
  22491. return new CompileTypeMetadata({ name: data['name'], moduleUrl: data['moduleUrl'], isHost: data['isHost'] });
  22492. };
  22493. CompileTypeMetadata.prototype.toJson = function () {
  22494. return {
  22495. // Note: Runtime type can't be serialized...
  22496. 'name': this.name,
  22497. 'moduleUrl': this.moduleUrl,
  22498. 'isHost': this.isHost
  22499. };
  22500. };
  22501. return CompileTypeMetadata;
  22502. })();
  22503. exports.CompileTypeMetadata = CompileTypeMetadata;
  22504. /**
  22505. * Metadata regarding compilation of a template.
  22506. */
  22507. var CompileTemplateMetadata = (function () {
  22508. function CompileTemplateMetadata(_a) {
  22509. var _b = _a === void 0 ? {} : _a, encapsulation = _b.encapsulation, template = _b.template, templateUrl = _b.templateUrl, styles = _b.styles, styleUrls = _b.styleUrls, ngContentSelectors = _b.ngContentSelectors;
  22510. this.encapsulation = lang_1.isPresent(encapsulation) ? encapsulation : view_1.ViewEncapsulation.Emulated;
  22511. this.template = template;
  22512. this.templateUrl = templateUrl;
  22513. this.styles = lang_1.isPresent(styles) ? styles : [];
  22514. this.styleUrls = lang_1.isPresent(styleUrls) ? styleUrls : [];
  22515. this.ngContentSelectors = lang_1.isPresent(ngContentSelectors) ? ngContentSelectors : [];
  22516. }
  22517. CompileTemplateMetadata.fromJson = function (data) {
  22518. return new CompileTemplateMetadata({
  22519. encapsulation: lang_1.isPresent(data['encapsulation']) ?
  22520. view_1.VIEW_ENCAPSULATION_VALUES[data['encapsulation']] :
  22521. data['encapsulation'],
  22522. template: data['template'],
  22523. templateUrl: data['templateUrl'],
  22524. styles: data['styles'],
  22525. styleUrls: data['styleUrls'],
  22526. ngContentSelectors: data['ngContentSelectors']
  22527. });
  22528. };
  22529. CompileTemplateMetadata.prototype.toJson = function () {
  22530. return {
  22531. 'encapsulation': lang_1.isPresent(this.encapsulation) ? lang_1.serializeEnum(this.encapsulation) : this.encapsulation,
  22532. 'template': this.template,
  22533. 'templateUrl': this.templateUrl,
  22534. 'styles': this.styles,
  22535. 'styleUrls': this.styleUrls,
  22536. 'ngContentSelectors': this.ngContentSelectors
  22537. };
  22538. };
  22539. return CompileTemplateMetadata;
  22540. })();
  22541. exports.CompileTemplateMetadata = CompileTemplateMetadata;
  22542. /**
  22543. * Metadata regarding compilation of a directive.
  22544. */
  22545. var CompileDirectiveMetadata = (function () {
  22546. function CompileDirectiveMetadata(_a) {
  22547. var _b = _a === void 0 ? {} : _a, type = _b.type, isComponent = _b.isComponent, dynamicLoadable = _b.dynamicLoadable, selector = _b.selector, exportAs = _b.exportAs, changeDetection = _b.changeDetection, inputs = _b.inputs, outputs = _b.outputs, hostListeners = _b.hostListeners, hostProperties = _b.hostProperties, hostAttributes = _b.hostAttributes, lifecycleHooks = _b.lifecycleHooks, template = _b.template;
  22548. this.type = type;
  22549. this.isComponent = isComponent;
  22550. this.dynamicLoadable = dynamicLoadable;
  22551. this.selector = selector;
  22552. this.exportAs = exportAs;
  22553. this.changeDetection = changeDetection;
  22554. this.inputs = inputs;
  22555. this.outputs = outputs;
  22556. this.hostListeners = hostListeners;
  22557. this.hostProperties = hostProperties;
  22558. this.hostAttributes = hostAttributes;
  22559. this.lifecycleHooks = lifecycleHooks;
  22560. this.template = template;
  22561. }
  22562. CompileDirectiveMetadata.create = function (_a) {
  22563. var _b = _a === void 0 ? {} : _a, type = _b.type, isComponent = _b.isComponent, dynamicLoadable = _b.dynamicLoadable, selector = _b.selector, exportAs = _b.exportAs, changeDetection = _b.changeDetection, inputs = _b.inputs, outputs = _b.outputs, host = _b.host, lifecycleHooks = _b.lifecycleHooks, template = _b.template;
  22564. var hostListeners = {};
  22565. var hostProperties = {};
  22566. var hostAttributes = {};
  22567. if (lang_1.isPresent(host)) {
  22568. collection_1.StringMapWrapper.forEach(host, function (value, key) {
  22569. var matches = lang_1.RegExpWrapper.firstMatch(HOST_REG_EXP, key);
  22570. if (lang_1.isBlank(matches)) {
  22571. hostAttributes[key] = value;
  22572. }
  22573. else if (lang_1.isPresent(matches[1])) {
  22574. hostProperties[matches[1]] = value;
  22575. }
  22576. else if (lang_1.isPresent(matches[2])) {
  22577. hostListeners[matches[2]] = value;
  22578. }
  22579. });
  22580. }
  22581. var inputsMap = {};
  22582. if (lang_1.isPresent(inputs)) {
  22583. inputs.forEach(function (bindConfig) {
  22584. // canonical syntax: `dirProp: elProp`
  22585. // if there is no `:`, use dirProp = elProp
  22586. var parts = util_1.splitAtColon(bindConfig, [bindConfig, bindConfig]);
  22587. inputsMap[parts[0]] = parts[1];
  22588. });
  22589. }
  22590. var outputsMap = {};
  22591. if (lang_1.isPresent(outputs)) {
  22592. outputs.forEach(function (bindConfig) {
  22593. // canonical syntax: `dirProp: elProp`
  22594. // if there is no `:`, use dirProp = elProp
  22595. var parts = util_1.splitAtColon(bindConfig, [bindConfig, bindConfig]);
  22596. outputsMap[parts[0]] = parts[1];
  22597. });
  22598. }
  22599. return new CompileDirectiveMetadata({
  22600. type: type,
  22601. isComponent: lang_1.normalizeBool(isComponent),
  22602. dynamicLoadable: lang_1.normalizeBool(dynamicLoadable),
  22603. selector: selector,
  22604. exportAs: exportAs,
  22605. changeDetection: changeDetection,
  22606. inputs: inputsMap,
  22607. outputs: outputsMap,
  22608. hostListeners: hostListeners,
  22609. hostProperties: hostProperties,
  22610. hostAttributes: hostAttributes,
  22611. lifecycleHooks: lang_1.isPresent(lifecycleHooks) ? lifecycleHooks : [],
  22612. template: template
  22613. });
  22614. };
  22615. CompileDirectiveMetadata.fromJson = function (data) {
  22616. return new CompileDirectiveMetadata({
  22617. isComponent: data['isComponent'],
  22618. dynamicLoadable: data['dynamicLoadable'],
  22619. selector: data['selector'],
  22620. exportAs: data['exportAs'],
  22621. type: lang_1.isPresent(data['type']) ? CompileTypeMetadata.fromJson(data['type']) : data['type'],
  22622. changeDetection: lang_1.isPresent(data['changeDetection']) ?
  22623. change_detection_1.CHANGE_DETECTION_STRATEGY_VALUES[data['changeDetection']] :
  22624. data['changeDetection'],
  22625. inputs: data['inputs'],
  22626. outputs: data['outputs'],
  22627. hostListeners: data['hostListeners'],
  22628. hostProperties: data['hostProperties'],
  22629. hostAttributes: data['hostAttributes'],
  22630. lifecycleHooks: data['lifecycleHooks'].map(function (hookValue) { return interfaces_1.LIFECYCLE_HOOKS_VALUES[hookValue]; }),
  22631. template: lang_1.isPresent(data['template']) ? CompileTemplateMetadata.fromJson(data['template']) :
  22632. data['template']
  22633. });
  22634. };
  22635. CompileDirectiveMetadata.prototype.toJson = function () {
  22636. return {
  22637. 'isComponent': this.isComponent,
  22638. 'dynamicLoadable': this.dynamicLoadable,
  22639. 'selector': this.selector,
  22640. 'exportAs': this.exportAs,
  22641. 'type': lang_1.isPresent(this.type) ? this.type.toJson() : this.type,
  22642. 'changeDetection': lang_1.isPresent(this.changeDetection) ? lang_1.serializeEnum(this.changeDetection) :
  22643. this.changeDetection,
  22644. 'inputs': this.inputs,
  22645. 'outputs': this.outputs,
  22646. 'hostListeners': this.hostListeners,
  22647. 'hostProperties': this.hostProperties,
  22648. 'hostAttributes': this.hostAttributes,
  22649. 'lifecycleHooks': this.lifecycleHooks.map(function (hook) { return lang_1.serializeEnum(hook); }),
  22650. 'template': lang_1.isPresent(this.template) ? this.template.toJson() : this.template
  22651. };
  22652. };
  22653. return CompileDirectiveMetadata;
  22654. })();
  22655. exports.CompileDirectiveMetadata = CompileDirectiveMetadata;
  22656. /**
  22657. * Construct {@link CompileDirectiveMetadata} from {@link ComponentTypeMetadata} and a selector.
  22658. */
  22659. function createHostComponentMeta(componentType, componentSelector) {
  22660. var template = selector_1.CssSelector.parse(componentSelector)[0].getMatchingElementTemplate();
  22661. return CompileDirectiveMetadata.create({
  22662. type: new CompileTypeMetadata({
  22663. runtime: Object,
  22664. name: "Host" + componentType.name,
  22665. moduleUrl: componentType.moduleUrl,
  22666. isHost: true
  22667. }),
  22668. template: new CompileTemplateMetadata({ template: template, templateUrl: '', styles: [], styleUrls: [], ngContentSelectors: [] }),
  22669. changeDetection: change_detection_1.ChangeDetectionStrategy.Default,
  22670. inputs: [],
  22671. outputs: [],
  22672. host: {},
  22673. lifecycleHooks: [],
  22674. isComponent: true,
  22675. dynamicLoadable: false,
  22676. selector: '*'
  22677. });
  22678. }
  22679. exports.createHostComponentMeta = createHostComponentMeta;
  22680. /***/ },
  22681. /* 154 */
  22682. /***/ function(module, exports, __webpack_require__) {
  22683. var collection_1 = __webpack_require__(12);
  22684. var lang_1 = __webpack_require__(5);
  22685. var exceptions_1 = __webpack_require__(14);
  22686. var _EMPTY_ATTR_VALUE = '';
  22687. // TODO: Can't use `const` here as
  22688. // in Dart this is not transpiled into `final` yet...
  22689. var _SELECTOR_REGEXP = lang_1.RegExpWrapper.create('(\\:not\\()|' +
  22690. '([-\\w]+)|' +
  22691. '(?:\\.([-\\w]+))|' +
  22692. '(?:\\[([-\\w*]+)(?:=([^\\]]*))?\\])|' +
  22693. '(\\))|' +
  22694. '(\\s*,\\s*)'); // ","
  22695. /**
  22696. * A css selector contains an element name,
  22697. * css classes and attribute/value pairs with the purpose
  22698. * of selecting subsets out of them.
  22699. */
  22700. var CssSelector = (function () {
  22701. function CssSelector() {
  22702. this.element = null;
  22703. this.classNames = [];
  22704. this.attrs = [];
  22705. this.notSelectors = [];
  22706. }
  22707. CssSelector.parse = function (selector) {
  22708. var results = [];
  22709. var _addResult = function (res, cssSel) {
  22710. if (cssSel.notSelectors.length > 0 && lang_1.isBlank(cssSel.element) &&
  22711. collection_1.ListWrapper.isEmpty(cssSel.classNames) && collection_1.ListWrapper.isEmpty(cssSel.attrs)) {
  22712. cssSel.element = "*";
  22713. }
  22714. res.push(cssSel);
  22715. };
  22716. var cssSelector = new CssSelector();
  22717. var matcher = lang_1.RegExpWrapper.matcher(_SELECTOR_REGEXP, selector);
  22718. var match;
  22719. var current = cssSelector;
  22720. var inNot = false;
  22721. while (lang_1.isPresent(match = lang_1.RegExpMatcherWrapper.next(matcher))) {
  22722. if (lang_1.isPresent(match[1])) {
  22723. if (inNot) {
  22724. throw new exceptions_1.BaseException('Nesting :not is not allowed in a selector');
  22725. }
  22726. inNot = true;
  22727. current = new CssSelector();
  22728. cssSelector.notSelectors.push(current);
  22729. }
  22730. if (lang_1.isPresent(match[2])) {
  22731. current.setElement(match[2]);
  22732. }
  22733. if (lang_1.isPresent(match[3])) {
  22734. current.addClassName(match[3]);
  22735. }
  22736. if (lang_1.isPresent(match[4])) {
  22737. current.addAttribute(match[4], match[5]);
  22738. }
  22739. if (lang_1.isPresent(match[6])) {
  22740. inNot = false;
  22741. current = cssSelector;
  22742. }
  22743. if (lang_1.isPresent(match[7])) {
  22744. if (inNot) {
  22745. throw new exceptions_1.BaseException('Multiple selectors in :not are not supported');
  22746. }
  22747. _addResult(results, cssSelector);
  22748. cssSelector = current = new CssSelector();
  22749. }
  22750. }
  22751. _addResult(results, cssSelector);
  22752. return results;
  22753. };
  22754. CssSelector.prototype.isElementSelector = function () {
  22755. return lang_1.isPresent(this.element) && collection_1.ListWrapper.isEmpty(this.classNames) &&
  22756. collection_1.ListWrapper.isEmpty(this.attrs) && this.notSelectors.length === 0;
  22757. };
  22758. CssSelector.prototype.setElement = function (element) {
  22759. if (element === void 0) { element = null; }
  22760. this.element = element;
  22761. };
  22762. /** Gets a template string for an element that matches the selector. */
  22763. CssSelector.prototype.getMatchingElementTemplate = function () {
  22764. var tagName = lang_1.isPresent(this.element) ? this.element : 'div';
  22765. var classAttr = this.classNames.length > 0 ? " class=\"" + this.classNames.join(' ') + "\"" : '';
  22766. var attrs = '';
  22767. for (var i = 0; i < this.attrs.length; i += 2) {
  22768. var attrName = this.attrs[i];
  22769. var attrValue = this.attrs[i + 1] !== '' ? "=\"" + this.attrs[i + 1] + "\"" : '';
  22770. attrs += " " + attrName + attrValue;
  22771. }
  22772. return "<" + tagName + classAttr + attrs + "></" + tagName + ">";
  22773. };
  22774. CssSelector.prototype.addAttribute = function (name, value) {
  22775. if (value === void 0) { value = _EMPTY_ATTR_VALUE; }
  22776. this.attrs.push(name);
  22777. if (lang_1.isPresent(value)) {
  22778. value = value.toLowerCase();
  22779. }
  22780. else {
  22781. value = _EMPTY_ATTR_VALUE;
  22782. }
  22783. this.attrs.push(value);
  22784. };
  22785. CssSelector.prototype.addClassName = function (name) { this.classNames.push(name.toLowerCase()); };
  22786. CssSelector.prototype.toString = function () {
  22787. var res = '';
  22788. if (lang_1.isPresent(this.element)) {
  22789. res += this.element;
  22790. }
  22791. if (lang_1.isPresent(this.classNames)) {
  22792. for (var i = 0; i < this.classNames.length; i++) {
  22793. res += '.' + this.classNames[i];
  22794. }
  22795. }
  22796. if (lang_1.isPresent(this.attrs)) {
  22797. for (var i = 0; i < this.attrs.length;) {
  22798. var attrName = this.attrs[i++];
  22799. var attrValue = this.attrs[i++];
  22800. res += '[' + attrName;
  22801. if (attrValue.length > 0) {
  22802. res += '=' + attrValue;
  22803. }
  22804. res += ']';
  22805. }
  22806. }
  22807. this.notSelectors.forEach(function (notSelector) { return res += ":not(" + notSelector + ")"; });
  22808. return res;
  22809. };
  22810. return CssSelector;
  22811. })();
  22812. exports.CssSelector = CssSelector;
  22813. /**
  22814. * Reads a list of CssSelectors and allows to calculate which ones
  22815. * are contained in a given CssSelector.
  22816. */
  22817. var SelectorMatcher = (function () {
  22818. function SelectorMatcher() {
  22819. this._elementMap = new collection_1.Map();
  22820. this._elementPartialMap = new collection_1.Map();
  22821. this._classMap = new collection_1.Map();
  22822. this._classPartialMap = new collection_1.Map();
  22823. this._attrValueMap = new collection_1.Map();
  22824. this._attrValuePartialMap = new collection_1.Map();
  22825. this._listContexts = [];
  22826. }
  22827. SelectorMatcher.createNotMatcher = function (notSelectors) {
  22828. var notMatcher = new SelectorMatcher();
  22829. notMatcher.addSelectables(notSelectors, null);
  22830. return notMatcher;
  22831. };
  22832. SelectorMatcher.prototype.addSelectables = function (cssSelectors, callbackCtxt) {
  22833. var listContext = null;
  22834. if (cssSelectors.length > 1) {
  22835. listContext = new SelectorListContext(cssSelectors);
  22836. this._listContexts.push(listContext);
  22837. }
  22838. for (var i = 0; i < cssSelectors.length; i++) {
  22839. this._addSelectable(cssSelectors[i], callbackCtxt, listContext);
  22840. }
  22841. };
  22842. /**
  22843. * Add an object that can be found later on by calling `match`.
  22844. * @param cssSelector A css selector
  22845. * @param callbackCtxt An opaque object that will be given to the callback of the `match` function
  22846. */
  22847. SelectorMatcher.prototype._addSelectable = function (cssSelector, callbackCtxt, listContext) {
  22848. var matcher = this;
  22849. var element = cssSelector.element;
  22850. var classNames = cssSelector.classNames;
  22851. var attrs = cssSelector.attrs;
  22852. var selectable = new SelectorContext(cssSelector, callbackCtxt, listContext);
  22853. if (lang_1.isPresent(element)) {
  22854. var isTerminal = attrs.length === 0 && classNames.length === 0;
  22855. if (isTerminal) {
  22856. this._addTerminal(matcher._elementMap, element, selectable);
  22857. }
  22858. else {
  22859. matcher = this._addPartial(matcher._elementPartialMap, element);
  22860. }
  22861. }
  22862. if (lang_1.isPresent(classNames)) {
  22863. for (var index = 0; index < classNames.length; index++) {
  22864. var isTerminal = attrs.length === 0 && index === classNames.length - 1;
  22865. var className = classNames[index];
  22866. if (isTerminal) {
  22867. this._addTerminal(matcher._classMap, className, selectable);
  22868. }
  22869. else {
  22870. matcher = this._addPartial(matcher._classPartialMap, className);
  22871. }
  22872. }
  22873. }
  22874. if (lang_1.isPresent(attrs)) {
  22875. for (var index = 0; index < attrs.length;) {
  22876. var isTerminal = index === attrs.length - 2;
  22877. var attrName = attrs[index++];
  22878. var attrValue = attrs[index++];
  22879. if (isTerminal) {
  22880. var terminalMap = matcher._attrValueMap;
  22881. var terminalValuesMap = terminalMap.get(attrName);
  22882. if (lang_1.isBlank(terminalValuesMap)) {
  22883. terminalValuesMap = new collection_1.Map();
  22884. terminalMap.set(attrName, terminalValuesMap);
  22885. }
  22886. this._addTerminal(terminalValuesMap, attrValue, selectable);
  22887. }
  22888. else {
  22889. var parttialMap = matcher._attrValuePartialMap;
  22890. var partialValuesMap = parttialMap.get(attrName);
  22891. if (lang_1.isBlank(partialValuesMap)) {
  22892. partialValuesMap = new collection_1.Map();
  22893. parttialMap.set(attrName, partialValuesMap);
  22894. }
  22895. matcher = this._addPartial(partialValuesMap, attrValue);
  22896. }
  22897. }
  22898. }
  22899. };
  22900. SelectorMatcher.prototype._addTerminal = function (map, name, selectable) {
  22901. var terminalList = map.get(name);
  22902. if (lang_1.isBlank(terminalList)) {
  22903. terminalList = [];
  22904. map.set(name, terminalList);
  22905. }
  22906. terminalList.push(selectable);
  22907. };
  22908. SelectorMatcher.prototype._addPartial = function (map, name) {
  22909. var matcher = map.get(name);
  22910. if (lang_1.isBlank(matcher)) {
  22911. matcher = new SelectorMatcher();
  22912. map.set(name, matcher);
  22913. }
  22914. return matcher;
  22915. };
  22916. /**
  22917. * Find the objects that have been added via `addSelectable`
  22918. * whose css selector is contained in the given css selector.
  22919. * @param cssSelector A css selector
  22920. * @param matchedCallback This callback will be called with the object handed into `addSelectable`
  22921. * @return boolean true if a match was found
  22922. */
  22923. SelectorMatcher.prototype.match = function (cssSelector, matchedCallback) {
  22924. var result = false;
  22925. var element = cssSelector.element;
  22926. var classNames = cssSelector.classNames;
  22927. var attrs = cssSelector.attrs;
  22928. for (var i = 0; i < this._listContexts.length; i++) {
  22929. this._listContexts[i].alreadyMatched = false;
  22930. }
  22931. result = this._matchTerminal(this._elementMap, element, cssSelector, matchedCallback) || result;
  22932. result = this._matchPartial(this._elementPartialMap, element, cssSelector, matchedCallback) ||
  22933. result;
  22934. if (lang_1.isPresent(classNames)) {
  22935. for (var index = 0; index < classNames.length; index++) {
  22936. var className = classNames[index];
  22937. result =
  22938. this._matchTerminal(this._classMap, className, cssSelector, matchedCallback) || result;
  22939. result =
  22940. this._matchPartial(this._classPartialMap, className, cssSelector, matchedCallback) ||
  22941. result;
  22942. }
  22943. }
  22944. if (lang_1.isPresent(attrs)) {
  22945. for (var index = 0; index < attrs.length;) {
  22946. var attrName = attrs[index++];
  22947. var attrValue = attrs[index++];
  22948. var terminalValuesMap = this._attrValueMap.get(attrName);
  22949. if (!lang_1.StringWrapper.equals(attrValue, _EMPTY_ATTR_VALUE)) {
  22950. result = this._matchTerminal(terminalValuesMap, _EMPTY_ATTR_VALUE, cssSelector, matchedCallback) ||
  22951. result;
  22952. }
  22953. result = this._matchTerminal(terminalValuesMap, attrValue, cssSelector, matchedCallback) ||
  22954. result;
  22955. var partialValuesMap = this._attrValuePartialMap.get(attrName);
  22956. if (!lang_1.StringWrapper.equals(attrValue, _EMPTY_ATTR_VALUE)) {
  22957. result = this._matchPartial(partialValuesMap, _EMPTY_ATTR_VALUE, cssSelector, matchedCallback) ||
  22958. result;
  22959. }
  22960. result =
  22961. this._matchPartial(partialValuesMap, attrValue, cssSelector, matchedCallback) || result;
  22962. }
  22963. }
  22964. return result;
  22965. };
  22966. /** @internal */
  22967. SelectorMatcher.prototype._matchTerminal = function (map, name, cssSelector, matchedCallback) {
  22968. if (lang_1.isBlank(map) || lang_1.isBlank(name)) {
  22969. return false;
  22970. }
  22971. var selectables = map.get(name);
  22972. var starSelectables = map.get("*");
  22973. if (lang_1.isPresent(starSelectables)) {
  22974. selectables = selectables.concat(starSelectables);
  22975. }
  22976. if (lang_1.isBlank(selectables)) {
  22977. return false;
  22978. }
  22979. var selectable;
  22980. var result = false;
  22981. for (var index = 0; index < selectables.length; index++) {
  22982. selectable = selectables[index];
  22983. result = selectable.finalize(cssSelector, matchedCallback) || result;
  22984. }
  22985. return result;
  22986. };
  22987. /** @internal */
  22988. SelectorMatcher.prototype._matchPartial = function (map, name, cssSelector, matchedCallback /*: (c: CssSelector, a: any) => void*/) {
  22989. if (lang_1.isBlank(map) || lang_1.isBlank(name)) {
  22990. return false;
  22991. }
  22992. var nestedSelector = map.get(name);
  22993. if (lang_1.isBlank(nestedSelector)) {
  22994. return false;
  22995. }
  22996. // TODO(perf): get rid of recursion and measure again
  22997. // TODO(perf): don't pass the whole selector into the recursion,
  22998. // but only the not processed parts
  22999. return nestedSelector.match(cssSelector, matchedCallback);
  23000. };
  23001. return SelectorMatcher;
  23002. })();
  23003. exports.SelectorMatcher = SelectorMatcher;
  23004. var SelectorListContext = (function () {
  23005. function SelectorListContext(selectors) {
  23006. this.selectors = selectors;
  23007. this.alreadyMatched = false;
  23008. }
  23009. return SelectorListContext;
  23010. })();
  23011. exports.SelectorListContext = SelectorListContext;
  23012. // Store context to pass back selector and context when a selector is matched
  23013. var SelectorContext = (function () {
  23014. function SelectorContext(selector, cbContext, listContext) {
  23015. this.selector = selector;
  23016. this.cbContext = cbContext;
  23017. this.listContext = listContext;
  23018. this.notSelectors = selector.notSelectors;
  23019. }
  23020. SelectorContext.prototype.finalize = function (cssSelector, callback) {
  23021. var result = true;
  23022. if (this.notSelectors.length > 0 &&
  23023. (lang_1.isBlank(this.listContext) || !this.listContext.alreadyMatched)) {
  23024. var notMatcher = SelectorMatcher.createNotMatcher(this.notSelectors);
  23025. result = !notMatcher.match(cssSelector, null);
  23026. }
  23027. if (result && lang_1.isPresent(callback) &&
  23028. (lang_1.isBlank(this.listContext) || !this.listContext.alreadyMatched)) {
  23029. if (lang_1.isPresent(this.listContext)) {
  23030. this.listContext.alreadyMatched = true;
  23031. }
  23032. callback(this.selector, this.cbContext);
  23033. }
  23034. return result;
  23035. };
  23036. return SelectorContext;
  23037. })();
  23038. exports.SelectorContext = SelectorContext;
  23039. /***/ },
  23040. /* 155 */
  23041. /***/ function(module, exports, __webpack_require__) {
  23042. var lang_1 = __webpack_require__(5);
  23043. var CAMEL_CASE_REGEXP = /([A-Z])/g;
  23044. var DASH_CASE_REGEXP = /-([a-z])/g;
  23045. var SINGLE_QUOTE_ESCAPE_STRING_RE = /'|\\|\n|\r|\$/g;
  23046. var DOUBLE_QUOTE_ESCAPE_STRING_RE = /"|\\|\n|\r|\$/g;
  23047. exports.MODULE_SUFFIX = lang_1.IS_DART ? '.dart' : '.js';
  23048. function camelCaseToDashCase(input) {
  23049. return lang_1.StringWrapper.replaceAllMapped(input, CAMEL_CASE_REGEXP, function (m) { return '-' + m[1].toLowerCase(); });
  23050. }
  23051. exports.camelCaseToDashCase = camelCaseToDashCase;
  23052. function dashCaseToCamelCase(input) {
  23053. return lang_1.StringWrapper.replaceAllMapped(input, DASH_CASE_REGEXP, function (m) { return m[1].toUpperCase(); });
  23054. }
  23055. exports.dashCaseToCamelCase = dashCaseToCamelCase;
  23056. function escapeSingleQuoteString(input) {
  23057. if (lang_1.isBlank(input)) {
  23058. return null;
  23059. }
  23060. return "'" + escapeString(input, SINGLE_QUOTE_ESCAPE_STRING_RE) + "'";
  23061. }
  23062. exports.escapeSingleQuoteString = escapeSingleQuoteString;
  23063. function escapeDoubleQuoteString(input) {
  23064. if (lang_1.isBlank(input)) {
  23065. return null;
  23066. }
  23067. return "\"" + escapeString(input, DOUBLE_QUOTE_ESCAPE_STRING_RE) + "\"";
  23068. }
  23069. exports.escapeDoubleQuoteString = escapeDoubleQuoteString;
  23070. function escapeString(input, re) {
  23071. return lang_1.StringWrapper.replaceAllMapped(input, re, function (match) {
  23072. if (match[0] == '$') {
  23073. return lang_1.IS_DART ? '\\$' : '$';
  23074. }
  23075. else if (match[0] == '\n') {
  23076. return '\\n';
  23077. }
  23078. else if (match[0] == '\r') {
  23079. return '\\r';
  23080. }
  23081. else {
  23082. return "\\" + match[0];
  23083. }
  23084. });
  23085. }
  23086. function codeGenExportVariable(name) {
  23087. if (lang_1.IS_DART) {
  23088. return "const " + name + " = ";
  23089. }
  23090. else {
  23091. return "var " + name + " = exports['" + name + "'] = ";
  23092. }
  23093. }
  23094. exports.codeGenExportVariable = codeGenExportVariable;
  23095. function codeGenConstConstructorCall(name) {
  23096. if (lang_1.IS_DART) {
  23097. return "const " + name;
  23098. }
  23099. else {
  23100. return "new " + name;
  23101. }
  23102. }
  23103. exports.codeGenConstConstructorCall = codeGenConstConstructorCall;
  23104. function codeGenValueFn(params, value, fnName) {
  23105. if (fnName === void 0) { fnName = ''; }
  23106. if (lang_1.IS_DART) {
  23107. return fnName + "(" + params.join(',') + ") => " + value;
  23108. }
  23109. else {
  23110. return "function " + fnName + "(" + params.join(',') + ") { return " + value + "; }";
  23111. }
  23112. }
  23113. exports.codeGenValueFn = codeGenValueFn;
  23114. function codeGenToString(expr) {
  23115. if (lang_1.IS_DART) {
  23116. return "'${" + expr + "}'";
  23117. }
  23118. else {
  23119. // JS automatically convets to string...
  23120. return expr;
  23121. }
  23122. }
  23123. exports.codeGenToString = codeGenToString;
  23124. function splitAtColon(input, defaultValues) {
  23125. var parts = lang_1.StringWrapper.split(input.trim(), /\s*:\s*/g);
  23126. if (parts.length > 1) {
  23127. return parts;
  23128. }
  23129. else {
  23130. return defaultValues;
  23131. }
  23132. }
  23133. exports.splitAtColon = splitAtColon;
  23134. /***/ },
  23135. /* 156 */
  23136. /***/ function(module, exports, __webpack_require__) {
  23137. var lang_1 = __webpack_require__(5);
  23138. var MODULE_REGEXP = /#MODULE\[([^\]]*)\]/g;
  23139. function moduleRef(moduleUrl) {
  23140. return "#MODULE[" + moduleUrl + "]";
  23141. }
  23142. exports.moduleRef = moduleRef;
  23143. /**
  23144. * Represents generated source code with module references. Internal to the Angular compiler.
  23145. */
  23146. var SourceModule = (function () {
  23147. function SourceModule(moduleUrl, sourceWithModuleRefs) {
  23148. this.moduleUrl = moduleUrl;
  23149. this.sourceWithModuleRefs = sourceWithModuleRefs;
  23150. }
  23151. SourceModule.prototype.getSourceWithImports = function () {
  23152. var _this = this;
  23153. var moduleAliases = {};
  23154. var imports = [];
  23155. var newSource = lang_1.StringWrapper.replaceAllMapped(this.sourceWithModuleRefs, MODULE_REGEXP, function (match) {
  23156. var moduleUrl = match[1];
  23157. var alias = moduleAliases[moduleUrl];
  23158. if (lang_1.isBlank(alias)) {
  23159. if (moduleUrl == _this.moduleUrl) {
  23160. alias = '';
  23161. }
  23162. else {
  23163. alias = "import" + imports.length;
  23164. imports.push([moduleUrl, alias]);
  23165. }
  23166. moduleAliases[moduleUrl] = alias;
  23167. }
  23168. return alias.length > 0 ? alias + "." : '';
  23169. });
  23170. return new SourceWithImports(newSource, imports);
  23171. };
  23172. return SourceModule;
  23173. })();
  23174. exports.SourceModule = SourceModule;
  23175. var SourceExpression = (function () {
  23176. function SourceExpression(declarations, expression) {
  23177. this.declarations = declarations;
  23178. this.expression = expression;
  23179. }
  23180. return SourceExpression;
  23181. })();
  23182. exports.SourceExpression = SourceExpression;
  23183. var SourceExpressions = (function () {
  23184. function SourceExpressions(declarations, expressions) {
  23185. this.declarations = declarations;
  23186. this.expressions = expressions;
  23187. }
  23188. return SourceExpressions;
  23189. })();
  23190. exports.SourceExpressions = SourceExpressions;
  23191. /**
  23192. * Represents generated source code with imports. Internal to the Angular compiler.
  23193. */
  23194. var SourceWithImports = (function () {
  23195. function SourceWithImports(source, imports) {
  23196. this.source = source;
  23197. this.imports = imports;
  23198. }
  23199. return SourceWithImports;
  23200. })();
  23201. exports.SourceWithImports = SourceWithImports;
  23202. /***/ },
  23203. /* 157 */
  23204. /***/ function(module, exports, __webpack_require__) {
  23205. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  23206. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  23207. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  23208. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  23209. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23210. };
  23211. var __metadata = (this && this.__metadata) || function (k, v) {
  23212. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  23213. };
  23214. var source_module_1 = __webpack_require__(156);
  23215. var change_detection_jit_generator_1 = __webpack_require__(52);
  23216. var change_definition_factory_1 = __webpack_require__(158);
  23217. var lang_1 = __webpack_require__(5);
  23218. var change_detection_1 = __webpack_require__(25);
  23219. var change_detector_codegen_1 = __webpack_require__(160);
  23220. var util_1 = __webpack_require__(155);
  23221. var di_1 = __webpack_require__(6);
  23222. var ABSTRACT_CHANGE_DETECTOR = "AbstractChangeDetector";
  23223. var UTIL = "ChangeDetectionUtil";
  23224. var CHANGE_DETECTOR_STATE = "ChangeDetectorState";
  23225. var ABSTRACT_CHANGE_DETECTOR_MODULE = source_module_1.moduleRef("package:angular2/src/core/change_detection/abstract_change_detector" + util_1.MODULE_SUFFIX);
  23226. var UTIL_MODULE = source_module_1.moduleRef("package:angular2/src/core/change_detection/change_detection_util" + util_1.MODULE_SUFFIX);
  23227. var PREGEN_PROTO_CHANGE_DETECTOR_MODULE = source_module_1.moduleRef("package:angular2/src/core/change_detection/pregen_proto_change_detector" + util_1.MODULE_SUFFIX);
  23228. var CONSTANTS_MODULE = source_module_1.moduleRef("package:angular2/src/core/change_detection/constants" + util_1.MODULE_SUFFIX);
  23229. var ChangeDetectionCompiler = (function () {
  23230. function ChangeDetectionCompiler(_genConfig) {
  23231. this._genConfig = _genConfig;
  23232. }
  23233. ChangeDetectionCompiler.prototype.compileComponentRuntime = function (componentType, strategy, parsedTemplate) {
  23234. var _this = this;
  23235. var changeDetectorDefinitions = change_definition_factory_1.createChangeDetectorDefinitions(componentType, strategy, this._genConfig, parsedTemplate);
  23236. return changeDetectorDefinitions.map(function (definition) {
  23237. return _this._createChangeDetectorFactory(definition);
  23238. });
  23239. };
  23240. ChangeDetectionCompiler.prototype._createChangeDetectorFactory = function (definition) {
  23241. if (lang_1.IS_DART || !this._genConfig.useJit) {
  23242. var proto = new change_detection_1.DynamicProtoChangeDetector(definition);
  23243. return function (dispatcher) { return proto.instantiate(dispatcher); };
  23244. }
  23245. else {
  23246. return new change_detection_jit_generator_1.ChangeDetectorJITGenerator(definition, UTIL, ABSTRACT_CHANGE_DETECTOR, CHANGE_DETECTOR_STATE)
  23247. .generate();
  23248. }
  23249. };
  23250. ChangeDetectionCompiler.prototype.compileComponentCodeGen = function (componentType, strategy, parsedTemplate) {
  23251. var changeDetectorDefinitions = change_definition_factory_1.createChangeDetectorDefinitions(componentType, strategy, this._genConfig, parsedTemplate);
  23252. var factories = [];
  23253. var index = 0;
  23254. var sourceParts = changeDetectorDefinitions.map(function (definition) {
  23255. var codegen;
  23256. var sourcePart;
  23257. // TODO(tbosch): move the 2 code generators to the same place, one with .dart and one with .ts
  23258. // suffix
  23259. // and have the same API for calling them!
  23260. if (lang_1.IS_DART) {
  23261. codegen = new change_detector_codegen_1.Codegen(PREGEN_PROTO_CHANGE_DETECTOR_MODULE);
  23262. var className = "_" + definition.id;
  23263. var typeRef = (index === 0 && componentType.isHost) ?
  23264. 'dynamic' :
  23265. "" + source_module_1.moduleRef(componentType.moduleUrl) + componentType.name;
  23266. codegen.generate(typeRef, className, definition);
  23267. factories.push(className + ".newChangeDetector");
  23268. sourcePart = codegen.toString();
  23269. }
  23270. else {
  23271. codegen = new change_detection_jit_generator_1.ChangeDetectorJITGenerator(definition, "" + UTIL_MODULE + UTIL, "" + ABSTRACT_CHANGE_DETECTOR_MODULE + ABSTRACT_CHANGE_DETECTOR, "" + CONSTANTS_MODULE + CHANGE_DETECTOR_STATE);
  23272. factories.push("function(dispatcher) { return new " + codegen.typeName + "(dispatcher); }");
  23273. sourcePart = codegen.generateSource();
  23274. }
  23275. index++;
  23276. return sourcePart;
  23277. });
  23278. return new source_module_1.SourceExpressions(sourceParts, factories);
  23279. };
  23280. ChangeDetectionCompiler = __decorate([
  23281. di_1.Injectable(),
  23282. __metadata('design:paramtypes', [change_detection_1.ChangeDetectorGenConfig])
  23283. ], ChangeDetectionCompiler);
  23284. return ChangeDetectionCompiler;
  23285. })();
  23286. exports.ChangeDetectionCompiler = ChangeDetectionCompiler;
  23287. /***/ },
  23288. /* 158 */
  23289. /***/ function(module, exports, __webpack_require__) {
  23290. var collection_1 = __webpack_require__(12);
  23291. var lang_1 = __webpack_require__(5);
  23292. var reflection_1 = __webpack_require__(16);
  23293. var change_detection_1 = __webpack_require__(25);
  23294. var template_ast_1 = __webpack_require__(159);
  23295. var interfaces_1 = __webpack_require__(89);
  23296. function createChangeDetectorDefinitions(componentType, componentStrategy, genConfig, parsedTemplate) {
  23297. var pvVisitors = [];
  23298. var visitor = new ProtoViewVisitor(null, pvVisitors, componentStrategy);
  23299. template_ast_1.templateVisitAll(visitor, parsedTemplate);
  23300. return createChangeDefinitions(pvVisitors, componentType, genConfig);
  23301. }
  23302. exports.createChangeDetectorDefinitions = createChangeDetectorDefinitions;
  23303. var ProtoViewVisitor = (function () {
  23304. function ProtoViewVisitor(parent, allVisitors, strategy) {
  23305. this.parent = parent;
  23306. this.allVisitors = allVisitors;
  23307. this.strategy = strategy;
  23308. this.boundTextCount = 0;
  23309. this.boundElementCount = 0;
  23310. this.variableNames = [];
  23311. this.bindingRecords = [];
  23312. this.eventRecords = [];
  23313. this.directiveRecords = [];
  23314. this.viewIndex = allVisitors.length;
  23315. allVisitors.push(this);
  23316. }
  23317. ProtoViewVisitor.prototype.visitEmbeddedTemplate = function (ast, context) {
  23318. this.boundElementCount++;
  23319. template_ast_1.templateVisitAll(this, ast.outputs);
  23320. for (var i = 0; i < ast.directives.length; i++) {
  23321. ast.directives[i].visit(this, i);
  23322. }
  23323. var childVisitor = new ProtoViewVisitor(this, this.allVisitors, change_detection_1.ChangeDetectionStrategy.Default);
  23324. // Attention: variables present on an embedded template count towards
  23325. // the embedded template and not the template anchor!
  23326. template_ast_1.templateVisitAll(childVisitor, ast.vars);
  23327. template_ast_1.templateVisitAll(childVisitor, ast.children);
  23328. return null;
  23329. };
  23330. ProtoViewVisitor.prototype.visitElement = function (ast, context) {
  23331. if (ast.isBound()) {
  23332. this.boundElementCount++;
  23333. }
  23334. template_ast_1.templateVisitAll(this, ast.inputs, null);
  23335. template_ast_1.templateVisitAll(this, ast.outputs);
  23336. template_ast_1.templateVisitAll(this, ast.exportAsVars);
  23337. for (var i = 0; i < ast.directives.length; i++) {
  23338. ast.directives[i].visit(this, i);
  23339. }
  23340. template_ast_1.templateVisitAll(this, ast.children);
  23341. return null;
  23342. };
  23343. ProtoViewVisitor.prototype.visitNgContent = function (ast, context) { return null; };
  23344. ProtoViewVisitor.prototype.visitVariable = function (ast, context) {
  23345. this.variableNames.push(ast.name);
  23346. return null;
  23347. };
  23348. ProtoViewVisitor.prototype.visitEvent = function (ast, directiveRecord) {
  23349. var bindingRecord = lang_1.isPresent(directiveRecord) ?
  23350. change_detection_1.BindingRecord.createForHostEvent(ast.handler, ast.fullName, directiveRecord) :
  23351. change_detection_1.BindingRecord.createForEvent(ast.handler, ast.fullName, this.boundElementCount - 1);
  23352. this.eventRecords.push(bindingRecord);
  23353. return null;
  23354. };
  23355. ProtoViewVisitor.prototype.visitElementProperty = function (ast, directiveRecord) {
  23356. var boundElementIndex = this.boundElementCount - 1;
  23357. var dirIndex = lang_1.isPresent(directiveRecord) ? directiveRecord.directiveIndex : null;
  23358. var bindingRecord;
  23359. if (ast.type === template_ast_1.PropertyBindingType.Property) {
  23360. bindingRecord =
  23361. lang_1.isPresent(dirIndex) ?
  23362. change_detection_1.BindingRecord.createForHostProperty(dirIndex, ast.value, ast.name) :
  23363. change_detection_1.BindingRecord.createForElementProperty(ast.value, boundElementIndex, ast.name);
  23364. }
  23365. else if (ast.type === template_ast_1.PropertyBindingType.Attribute) {
  23366. bindingRecord =
  23367. lang_1.isPresent(dirIndex) ?
  23368. change_detection_1.BindingRecord.createForHostAttribute(dirIndex, ast.value, ast.name) :
  23369. change_detection_1.BindingRecord.createForElementAttribute(ast.value, boundElementIndex, ast.name);
  23370. }
  23371. else if (ast.type === template_ast_1.PropertyBindingType.Class) {
  23372. bindingRecord =
  23373. lang_1.isPresent(dirIndex) ?
  23374. change_detection_1.BindingRecord.createForHostClass(dirIndex, ast.value, ast.name) :
  23375. change_detection_1.BindingRecord.createForElementClass(ast.value, boundElementIndex, ast.name);
  23376. }
  23377. else if (ast.type === template_ast_1.PropertyBindingType.Style) {
  23378. bindingRecord =
  23379. lang_1.isPresent(dirIndex) ?
  23380. change_detection_1.BindingRecord.createForHostStyle(dirIndex, ast.value, ast.name, ast.unit) :
  23381. change_detection_1.BindingRecord.createForElementStyle(ast.value, boundElementIndex, ast.name, ast.unit);
  23382. }
  23383. this.bindingRecords.push(bindingRecord);
  23384. return null;
  23385. };
  23386. ProtoViewVisitor.prototype.visitAttr = function (ast, context) { return null; };
  23387. ProtoViewVisitor.prototype.visitBoundText = function (ast, context) {
  23388. var boundTextIndex = this.boundTextCount++;
  23389. this.bindingRecords.push(change_detection_1.BindingRecord.createForTextNode(ast.value, boundTextIndex));
  23390. return null;
  23391. };
  23392. ProtoViewVisitor.prototype.visitText = function (ast, context) { return null; };
  23393. ProtoViewVisitor.prototype.visitDirective = function (ast, directiveIndexAsNumber) {
  23394. var directiveIndex = new change_detection_1.DirectiveIndex(this.boundElementCount - 1, directiveIndexAsNumber);
  23395. var directiveMetadata = ast.directive;
  23396. var directiveRecord = new change_detection_1.DirectiveRecord({
  23397. directiveIndex: directiveIndex,
  23398. callAfterContentInit: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.AfterContentInit) !== -1,
  23399. callAfterContentChecked: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.AfterContentChecked) !== -1,
  23400. callAfterViewInit: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.AfterViewInit) !== -1,
  23401. callAfterViewChecked: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.AfterViewChecked) !== -1,
  23402. callOnChanges: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.OnChanges) !== -1,
  23403. callDoCheck: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.DoCheck) !== -1,
  23404. callOnInit: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.OnInit) !== -1,
  23405. changeDetection: directiveMetadata.changeDetection
  23406. });
  23407. this.directiveRecords.push(directiveRecord);
  23408. template_ast_1.templateVisitAll(this, ast.inputs, directiveRecord);
  23409. var bindingRecords = this.bindingRecords;
  23410. if (directiveRecord.callOnChanges) {
  23411. bindingRecords.push(change_detection_1.BindingRecord.createDirectiveOnChanges(directiveRecord));
  23412. }
  23413. if (directiveRecord.callOnInit) {
  23414. bindingRecords.push(change_detection_1.BindingRecord.createDirectiveOnInit(directiveRecord));
  23415. }
  23416. if (directiveRecord.callDoCheck) {
  23417. bindingRecords.push(change_detection_1.BindingRecord.createDirectiveDoCheck(directiveRecord));
  23418. }
  23419. template_ast_1.templateVisitAll(this, ast.hostProperties, directiveRecord);
  23420. template_ast_1.templateVisitAll(this, ast.hostEvents, directiveRecord);
  23421. template_ast_1.templateVisitAll(this, ast.exportAsVars);
  23422. return null;
  23423. };
  23424. ProtoViewVisitor.prototype.visitDirectiveProperty = function (ast, directiveRecord) {
  23425. // TODO: these setters should eventually be created by change detection, to make
  23426. // it monomorphic!
  23427. var setter = reflection_1.reflector.setter(ast.directiveName);
  23428. this.bindingRecords.push(change_detection_1.BindingRecord.createForDirective(ast.value, ast.directiveName, setter, directiveRecord));
  23429. return null;
  23430. };
  23431. return ProtoViewVisitor;
  23432. })();
  23433. function createChangeDefinitions(pvVisitors, componentType, genConfig) {
  23434. var pvVariableNames = _collectNestedProtoViewsVariableNames(pvVisitors);
  23435. return pvVisitors.map(function (pvVisitor) {
  23436. var id = componentType.name + "_" + pvVisitor.viewIndex;
  23437. return new change_detection_1.ChangeDetectorDefinition(id, pvVisitor.strategy, pvVariableNames[pvVisitor.viewIndex], pvVisitor.bindingRecords, pvVisitor.eventRecords, pvVisitor.directiveRecords, genConfig);
  23438. });
  23439. }
  23440. function _collectNestedProtoViewsVariableNames(pvVisitors) {
  23441. var nestedPvVariableNames = collection_1.ListWrapper.createFixedSize(pvVisitors.length);
  23442. pvVisitors.forEach(function (pv) {
  23443. var parentVariableNames = lang_1.isPresent(pv.parent) ? nestedPvVariableNames[pv.parent.viewIndex] : [];
  23444. nestedPvVariableNames[pv.viewIndex] = parentVariableNames.concat(pv.variableNames);
  23445. });
  23446. return nestedPvVariableNames;
  23447. }
  23448. /***/ },
  23449. /* 159 */
  23450. /***/ function(module, exports, __webpack_require__) {
  23451. var lang_1 = __webpack_require__(5);
  23452. /**
  23453. * A segment of text within the template.
  23454. */
  23455. var TextAst = (function () {
  23456. function TextAst(value, ngContentIndex, sourceSpan) {
  23457. this.value = value;
  23458. this.ngContentIndex = ngContentIndex;
  23459. this.sourceSpan = sourceSpan;
  23460. }
  23461. TextAst.prototype.visit = function (visitor, context) { return visitor.visitText(this, context); };
  23462. return TextAst;
  23463. })();
  23464. exports.TextAst = TextAst;
  23465. /**
  23466. * A bound expression within the text of a template.
  23467. */
  23468. var BoundTextAst = (function () {
  23469. function BoundTextAst(value, ngContentIndex, sourceSpan) {
  23470. this.value = value;
  23471. this.ngContentIndex = ngContentIndex;
  23472. this.sourceSpan = sourceSpan;
  23473. }
  23474. BoundTextAst.prototype.visit = function (visitor, context) {
  23475. return visitor.visitBoundText(this, context);
  23476. };
  23477. return BoundTextAst;
  23478. })();
  23479. exports.BoundTextAst = BoundTextAst;
  23480. /**
  23481. * A plain attribute on an element.
  23482. */
  23483. var AttrAst = (function () {
  23484. function AttrAst(name, value, sourceSpan) {
  23485. this.name = name;
  23486. this.value = value;
  23487. this.sourceSpan = sourceSpan;
  23488. }
  23489. AttrAst.prototype.visit = function (visitor, context) { return visitor.visitAttr(this, context); };
  23490. return AttrAst;
  23491. })();
  23492. exports.AttrAst = AttrAst;
  23493. /**
  23494. * A binding for an element property (e.g. `[property]="expression"`).
  23495. */
  23496. var BoundElementPropertyAst = (function () {
  23497. function BoundElementPropertyAst(name, type, value, unit, sourceSpan) {
  23498. this.name = name;
  23499. this.type = type;
  23500. this.value = value;
  23501. this.unit = unit;
  23502. this.sourceSpan = sourceSpan;
  23503. }
  23504. BoundElementPropertyAst.prototype.visit = function (visitor, context) {
  23505. return visitor.visitElementProperty(this, context);
  23506. };
  23507. return BoundElementPropertyAst;
  23508. })();
  23509. exports.BoundElementPropertyAst = BoundElementPropertyAst;
  23510. /**
  23511. * A binding for an element event (e.g. `(event)="handler()"`).
  23512. */
  23513. var BoundEventAst = (function () {
  23514. function BoundEventAst(name, target, handler, sourceSpan) {
  23515. this.name = name;
  23516. this.target = target;
  23517. this.handler = handler;
  23518. this.sourceSpan = sourceSpan;
  23519. }
  23520. BoundEventAst.prototype.visit = function (visitor, context) {
  23521. return visitor.visitEvent(this, context);
  23522. };
  23523. Object.defineProperty(BoundEventAst.prototype, "fullName", {
  23524. get: function () {
  23525. if (lang_1.isPresent(this.target)) {
  23526. return this.target + ":" + this.name;
  23527. }
  23528. else {
  23529. return this.name;
  23530. }
  23531. },
  23532. enumerable: true,
  23533. configurable: true
  23534. });
  23535. return BoundEventAst;
  23536. })();
  23537. exports.BoundEventAst = BoundEventAst;
  23538. /**
  23539. * A variable declaration on an element (e.g. `#var="expression"`).
  23540. */
  23541. var VariableAst = (function () {
  23542. function VariableAst(name, value, sourceSpan) {
  23543. this.name = name;
  23544. this.value = value;
  23545. this.sourceSpan = sourceSpan;
  23546. }
  23547. VariableAst.prototype.visit = function (visitor, context) {
  23548. return visitor.visitVariable(this, context);
  23549. };
  23550. return VariableAst;
  23551. })();
  23552. exports.VariableAst = VariableAst;
  23553. /**
  23554. * An element declaration in a template.
  23555. */
  23556. var ElementAst = (function () {
  23557. function ElementAst(name, attrs, inputs, outputs, exportAsVars, directives, children, ngContentIndex, sourceSpan) {
  23558. this.name = name;
  23559. this.attrs = attrs;
  23560. this.inputs = inputs;
  23561. this.outputs = outputs;
  23562. this.exportAsVars = exportAsVars;
  23563. this.directives = directives;
  23564. this.children = children;
  23565. this.ngContentIndex = ngContentIndex;
  23566. this.sourceSpan = sourceSpan;
  23567. }
  23568. ElementAst.prototype.visit = function (visitor, context) {
  23569. return visitor.visitElement(this, context);
  23570. };
  23571. /**
  23572. * Whether the element has any active bindings (inputs, outputs, vars, or directives).
  23573. */
  23574. ElementAst.prototype.isBound = function () {
  23575. return (this.inputs.length > 0 || this.outputs.length > 0 || this.exportAsVars.length > 0 ||
  23576. this.directives.length > 0);
  23577. };
  23578. /**
  23579. * Get the component associated with this element, if any.
  23580. */
  23581. ElementAst.prototype.getComponent = function () {
  23582. return this.directives.length > 0 && this.directives[0].directive.isComponent ?
  23583. this.directives[0].directive :
  23584. null;
  23585. };
  23586. return ElementAst;
  23587. })();
  23588. exports.ElementAst = ElementAst;
  23589. /**
  23590. * A `<template>` element included in an Angular template.
  23591. */
  23592. var EmbeddedTemplateAst = (function () {
  23593. function EmbeddedTemplateAst(attrs, outputs, vars, directives, children, ngContentIndex, sourceSpan) {
  23594. this.attrs = attrs;
  23595. this.outputs = outputs;
  23596. this.vars = vars;
  23597. this.directives = directives;
  23598. this.children = children;
  23599. this.ngContentIndex = ngContentIndex;
  23600. this.sourceSpan = sourceSpan;
  23601. }
  23602. EmbeddedTemplateAst.prototype.visit = function (visitor, context) {
  23603. return visitor.visitEmbeddedTemplate(this, context);
  23604. };
  23605. return EmbeddedTemplateAst;
  23606. })();
  23607. exports.EmbeddedTemplateAst = EmbeddedTemplateAst;
  23608. /**
  23609. * A directive property with a bound value (e.g. `*ngIf="condition").
  23610. */
  23611. var BoundDirectivePropertyAst = (function () {
  23612. function BoundDirectivePropertyAst(directiveName, templateName, value, sourceSpan) {
  23613. this.directiveName = directiveName;
  23614. this.templateName = templateName;
  23615. this.value = value;
  23616. this.sourceSpan = sourceSpan;
  23617. }
  23618. BoundDirectivePropertyAst.prototype.visit = function (visitor, context) {
  23619. return visitor.visitDirectiveProperty(this, context);
  23620. };
  23621. return BoundDirectivePropertyAst;
  23622. })();
  23623. exports.BoundDirectivePropertyAst = BoundDirectivePropertyAst;
  23624. /**
  23625. * A directive declared on an element.
  23626. */
  23627. var DirectiveAst = (function () {
  23628. function DirectiveAst(directive, inputs, hostProperties, hostEvents, exportAsVars, sourceSpan) {
  23629. this.directive = directive;
  23630. this.inputs = inputs;
  23631. this.hostProperties = hostProperties;
  23632. this.hostEvents = hostEvents;
  23633. this.exportAsVars = exportAsVars;
  23634. this.sourceSpan = sourceSpan;
  23635. }
  23636. DirectiveAst.prototype.visit = function (visitor, context) {
  23637. return visitor.visitDirective(this, context);
  23638. };
  23639. return DirectiveAst;
  23640. })();
  23641. exports.DirectiveAst = DirectiveAst;
  23642. /**
  23643. * Position where content is to be projected (instance of `<ng-content>` in a template).
  23644. */
  23645. var NgContentAst = (function () {
  23646. function NgContentAst(index, ngContentIndex, sourceSpan) {
  23647. this.index = index;
  23648. this.ngContentIndex = ngContentIndex;
  23649. this.sourceSpan = sourceSpan;
  23650. }
  23651. NgContentAst.prototype.visit = function (visitor, context) {
  23652. return visitor.visitNgContent(this, context);
  23653. };
  23654. return NgContentAst;
  23655. })();
  23656. exports.NgContentAst = NgContentAst;
  23657. /**
  23658. * Enumeration of types of property bindings.
  23659. */
  23660. (function (PropertyBindingType) {
  23661. /**
  23662. * A normal binding to a property (e.g. `[property]="expression"`).
  23663. */
  23664. PropertyBindingType[PropertyBindingType["Property"] = 0] = "Property";
  23665. /**
  23666. * A binding to an element attribute (e.g. `[attr.name]="expression"`).
  23667. */
  23668. PropertyBindingType[PropertyBindingType["Attribute"] = 1] = "Attribute";
  23669. /**
  23670. * A binding to a CSS class (e.g. `[class.name]="condition"`).
  23671. */
  23672. PropertyBindingType[PropertyBindingType["Class"] = 2] = "Class";
  23673. /**
  23674. * A binding to a style rule (e.g. `[style.rule]="expression"`).
  23675. */
  23676. PropertyBindingType[PropertyBindingType["Style"] = 3] = "Style";
  23677. })(exports.PropertyBindingType || (exports.PropertyBindingType = {}));
  23678. var PropertyBindingType = exports.PropertyBindingType;
  23679. /**
  23680. * Visit every node in a list of {@link TemplateAst}s with the given {@link TemplateAstVisitor}.
  23681. */
  23682. function templateVisitAll(visitor, asts, context) {
  23683. if (context === void 0) { context = null; }
  23684. var result = [];
  23685. asts.forEach(function (ast) {
  23686. var astResult = ast.visit(visitor, context);
  23687. if (lang_1.isPresent(astResult)) {
  23688. result.push(astResult);
  23689. }
  23690. });
  23691. return result;
  23692. }
  23693. exports.templateVisitAll = templateVisitAll;
  23694. /***/ },
  23695. /* 160 */
  23696. /***/ function(module, exports) {
  23697. // Note: This class is only here so that we can reference it from TypeScript code.
  23698. // The actual implementation lives under modules_dart.
  23699. // TODO(tbosch): Move the corresponding code into angular2/src/compiler once
  23700. // the new compiler is done.
  23701. var Codegen = (function () {
  23702. function Codegen(moduleAlias) {
  23703. }
  23704. Codegen.prototype.generate = function (typeName, changeDetectorTypeName, def) {
  23705. throw "Not implemented in JS";
  23706. };
  23707. Codegen.prototype.toString = function () { throw "Not implemented in JS"; };
  23708. return Codegen;
  23709. })();
  23710. exports.Codegen = Codegen;
  23711. /***/ },
  23712. /* 161 */
  23713. /***/ function(module, exports, __webpack_require__) {
  23714. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  23715. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  23716. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  23717. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  23718. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23719. };
  23720. var __metadata = (this && this.__metadata) || function (k, v) {
  23721. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  23722. };
  23723. var source_module_1 = __webpack_require__(156);
  23724. var view_1 = __webpack_require__(56);
  23725. var xhr_1 = __webpack_require__(149);
  23726. var lang_1 = __webpack_require__(5);
  23727. var async_1 = __webpack_require__(60);
  23728. var shadow_css_1 = __webpack_require__(162);
  23729. var url_resolver_1 = __webpack_require__(148);
  23730. var style_url_resolver_1 = __webpack_require__(163);
  23731. var util_1 = __webpack_require__(155);
  23732. var di_1 = __webpack_require__(6);
  23733. var view_factory_1 = __webpack_require__(164);
  23734. var StyleCompiler = (function () {
  23735. function StyleCompiler(_xhr, _urlResolver) {
  23736. this._xhr = _xhr;
  23737. this._urlResolver = _urlResolver;
  23738. this._styleCache = new Map();
  23739. this._shadowCss = new shadow_css_1.ShadowCss();
  23740. }
  23741. StyleCompiler.prototype.compileComponentRuntime = function (template) {
  23742. var styles = template.styles;
  23743. var styleAbsUrls = template.styleUrls;
  23744. return this._loadStyles(styles, styleAbsUrls, template.encapsulation === view_1.ViewEncapsulation.Emulated);
  23745. };
  23746. StyleCompiler.prototype.compileComponentCodeGen = function (template) {
  23747. var shim = template.encapsulation === view_1.ViewEncapsulation.Emulated;
  23748. return this._styleCodeGen(template.styles, template.styleUrls, shim);
  23749. };
  23750. StyleCompiler.prototype.compileStylesheetCodeGen = function (stylesheetUrl, cssText) {
  23751. var styleWithImports = style_url_resolver_1.extractStyleUrls(this._urlResolver, stylesheetUrl, cssText);
  23752. return [
  23753. this._styleModule(stylesheetUrl, false, this._styleCodeGen([styleWithImports.style], styleWithImports.styleUrls, false)),
  23754. this._styleModule(stylesheetUrl, true, this._styleCodeGen([styleWithImports.style], styleWithImports.styleUrls, true))
  23755. ];
  23756. };
  23757. StyleCompiler.prototype.clearCache = function () { this._styleCache.clear(); };
  23758. StyleCompiler.prototype._loadStyles = function (plainStyles, absUrls, encapsulate) {
  23759. var _this = this;
  23760. var promises = absUrls.map(function (absUrl) {
  23761. var cacheKey = "" + absUrl + (encapsulate ? '.shim' : '');
  23762. var result = _this._styleCache.get(cacheKey);
  23763. if (lang_1.isBlank(result)) {
  23764. result = _this._xhr.get(absUrl).then(function (style) {
  23765. var styleWithImports = style_url_resolver_1.extractStyleUrls(_this._urlResolver, absUrl, style);
  23766. return _this._loadStyles([styleWithImports.style], styleWithImports.styleUrls, encapsulate);
  23767. });
  23768. _this._styleCache.set(cacheKey, result);
  23769. }
  23770. return result;
  23771. });
  23772. return async_1.PromiseWrapper.all(promises).then(function (nestedStyles) {
  23773. var result = plainStyles.map(function (plainStyle) { return _this._shimIfNeeded(plainStyle, encapsulate); });
  23774. nestedStyles.forEach(function (styles) { return result.push(styles); });
  23775. return result;
  23776. });
  23777. };
  23778. StyleCompiler.prototype._styleCodeGen = function (plainStyles, absUrls, shim) {
  23779. var _this = this;
  23780. var arrayPrefix = lang_1.IS_DART ? "const" : '';
  23781. var styleExpressions = plainStyles.map(function (plainStyle) { return util_1.escapeSingleQuoteString(_this._shimIfNeeded(plainStyle, shim)); });
  23782. for (var i = 0; i < absUrls.length; i++) {
  23783. var moduleUrl = this._createModuleUrl(absUrls[i], shim);
  23784. styleExpressions.push(source_module_1.moduleRef(moduleUrl) + "STYLES");
  23785. }
  23786. var expressionSource = arrayPrefix + " [" + styleExpressions.join(',') + "]";
  23787. return new source_module_1.SourceExpression([], expressionSource);
  23788. };
  23789. StyleCompiler.prototype._styleModule = function (stylesheetUrl, shim, expression) {
  23790. var moduleSource = "\n " + expression.declarations.join('\n') + "\n " + util_1.codeGenExportVariable('STYLES') + expression.expression + ";\n ";
  23791. return new source_module_1.SourceModule(this._createModuleUrl(stylesheetUrl, shim), moduleSource);
  23792. };
  23793. StyleCompiler.prototype._shimIfNeeded = function (style, shim) {
  23794. return shim ? this._shadowCss.shimCssText(style, view_factory_1.CONTENT_ATTR, view_factory_1.HOST_ATTR) : style;
  23795. };
  23796. StyleCompiler.prototype._createModuleUrl = function (stylesheetUrl, shim) {
  23797. return shim ? stylesheetUrl + ".shim" + util_1.MODULE_SUFFIX : "" + stylesheetUrl + util_1.MODULE_SUFFIX;
  23798. };
  23799. StyleCompiler = __decorate([
  23800. di_1.Injectable(),
  23801. __metadata('design:paramtypes', [xhr_1.XHR, url_resolver_1.UrlResolver])
  23802. ], StyleCompiler);
  23803. return StyleCompiler;
  23804. })();
  23805. exports.StyleCompiler = StyleCompiler;
  23806. /***/ },
  23807. /* 162 */
  23808. /***/ function(module, exports, __webpack_require__) {
  23809. var collection_1 = __webpack_require__(12);
  23810. var lang_1 = __webpack_require__(5);
  23811. /**
  23812. * This file is a port of shadowCSS from webcomponents.js to TypeScript.
  23813. *
  23814. * Please make sure to keep to edits in sync with the source file.
  23815. *
  23816. * Source:
  23817. * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js
  23818. *
  23819. * The original file level comment is reproduced below
  23820. */
  23821. /*
  23822. This is a limited shim for ShadowDOM css styling.
  23823. https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#styles
  23824. The intention here is to support only the styling features which can be
  23825. relatively simply implemented. The goal is to allow users to avoid the
  23826. most obvious pitfalls and do so without compromising performance significantly.
  23827. For ShadowDOM styling that's not covered here, a set of best practices
  23828. can be provided that should allow users to accomplish more complex styling.
  23829. The following is a list of specific ShadowDOM styling features and a brief
  23830. discussion of the approach used to shim.
  23831. Shimmed features:
  23832. * :host, :host-context: ShadowDOM allows styling of the shadowRoot's host
  23833. element using the :host rule. To shim this feature, the :host styles are
  23834. reformatted and prefixed with a given scope name and promoted to a
  23835. document level stylesheet.
  23836. For example, given a scope name of .foo, a rule like this:
  23837. :host {
  23838. background: red;
  23839. }
  23840. }
  23841. becomes:
  23842. .foo {
  23843. background: red;
  23844. }
  23845. * encapsultion: Styles defined within ShadowDOM, apply only to
  23846. dom inside the ShadowDOM. Polymer uses one of two techniques to imlement
  23847. this feature.
  23848. By default, rules are prefixed with the host element tag name
  23849. as a descendant selector. This ensures styling does not leak out of the 'top'
  23850. of the element's ShadowDOM. For example,
  23851. div {
  23852. font-weight: bold;
  23853. }
  23854. becomes:
  23855. x-foo div {
  23856. font-weight: bold;
  23857. }
  23858. becomes:
  23859. Alternatively, if WebComponents.ShadowCSS.strictStyling is set to true then
  23860. selectors are scoped by adding an attribute selector suffix to each
  23861. simple selector that contains the host element tag name. Each element
  23862. in the element's ShadowDOM template is also given the scope attribute.
  23863. Thus, these rules match only elements that have the scope attribute.
  23864. For example, given a scope name of x-foo, a rule like this:
  23865. div {
  23866. font-weight: bold;
  23867. }
  23868. becomes:
  23869. div[x-foo] {
  23870. font-weight: bold;
  23871. }
  23872. Note that elements that are dynamically added to a scope must have the scope
  23873. selector added to them manually.
  23874. * upper/lower bound encapsulation: Styles which are defined outside a
  23875. shadowRoot should not cross the ShadowDOM boundary and should not apply
  23876. inside a shadowRoot.
  23877. This styling behavior is not emulated. Some possible ways to do this that
  23878. were rejected due to complexity and/or performance concerns include: (1) reset
  23879. every possible property for every possible selector for a given scope name;
  23880. (2) re-implement css in javascript.
  23881. As an alternative, users should make sure to use selectors
  23882. specific to the scope in which they are working.
  23883. * ::distributed: This behavior is not emulated. It's often not necessary
  23884. to style the contents of a specific insertion point and instead, descendants
  23885. of the host element can be styled selectively. Users can also create an
  23886. extra node around an insertion point and style that node's contents
  23887. via descendent selectors. For example, with a shadowRoot like this:
  23888. <style>
  23889. ::content(div) {
  23890. background: red;
  23891. }
  23892. </style>
  23893. <content></content>
  23894. could become:
  23895. <style>
  23896. / *@polyfill .content-container div * /
  23897. ::content(div) {
  23898. background: red;
  23899. }
  23900. </style>
  23901. <div class="content-container">
  23902. <content></content>
  23903. </div>
  23904. Note the use of @polyfill in the comment above a ShadowDOM specific style
  23905. declaration. This is a directive to the styling shim to use the selector
  23906. in comments in lieu of the next selector when running under polyfill.
  23907. */
  23908. var ShadowCss = (function () {
  23909. function ShadowCss() {
  23910. this.strictStyling = true;
  23911. }
  23912. /*
  23913. * Shim some cssText with the given selector. Returns cssText that can
  23914. * be included in the document via WebComponents.ShadowCSS.addCssToDocument(css).
  23915. *
  23916. * When strictStyling is true:
  23917. * - selector is the attribute added to all elements inside the host,
  23918. * - hostSelector is the attribute added to the host itself.
  23919. */
  23920. ShadowCss.prototype.shimCssText = function (cssText, selector, hostSelector) {
  23921. if (hostSelector === void 0) { hostSelector = ''; }
  23922. cssText = stripComments(cssText);
  23923. cssText = this._insertDirectives(cssText);
  23924. return this._scopeCssText(cssText, selector, hostSelector);
  23925. };
  23926. ShadowCss.prototype._insertDirectives = function (cssText) {
  23927. cssText = this._insertPolyfillDirectivesInCssText(cssText);
  23928. return this._insertPolyfillRulesInCssText(cssText);
  23929. };
  23930. /*
  23931. * Process styles to convert native ShadowDOM rules that will trip
  23932. * up the css parser; we rely on decorating the stylesheet with inert rules.
  23933. *
  23934. * For example, we convert this rule:
  23935. *
  23936. * polyfill-next-selector { content: ':host menu-item'; }
  23937. * ::content menu-item {
  23938. *
  23939. * to this:
  23940. *
  23941. * scopeName menu-item {
  23942. *
  23943. **/
  23944. ShadowCss.prototype._insertPolyfillDirectivesInCssText = function (cssText) {
  23945. // Difference with webcomponents.js: does not handle comments
  23946. return lang_1.StringWrapper.replaceAllMapped(cssText, _cssContentNextSelectorRe, function (m) { return m[1] + '{'; });
  23947. };
  23948. /*
  23949. * Process styles to add rules which will only apply under the polyfill
  23950. *
  23951. * For example, we convert this rule:
  23952. *
  23953. * polyfill-rule {
  23954. * content: ':host menu-item';
  23955. * ...
  23956. * }
  23957. *
  23958. * to this:
  23959. *
  23960. * scopeName menu-item {...}
  23961. *
  23962. **/
  23963. ShadowCss.prototype._insertPolyfillRulesInCssText = function (cssText) {
  23964. // Difference with webcomponents.js: does not handle comments
  23965. return lang_1.StringWrapper.replaceAllMapped(cssText, _cssContentRuleRe, function (m) {
  23966. var rule = m[0];
  23967. rule = lang_1.StringWrapper.replace(rule, m[1], '');
  23968. rule = lang_1.StringWrapper.replace(rule, m[2], '');
  23969. return m[3] + rule;
  23970. });
  23971. };
  23972. /* Ensure styles are scoped. Pseudo-scoping takes a rule like:
  23973. *
  23974. * .foo {... }
  23975. *
  23976. * and converts this to
  23977. *
  23978. * scopeName .foo { ... }
  23979. */
  23980. ShadowCss.prototype._scopeCssText = function (cssText, scopeSelector, hostSelector) {
  23981. var unscoped = this._extractUnscopedRulesFromCssText(cssText);
  23982. cssText = this._insertPolyfillHostInCssText(cssText);
  23983. cssText = this._convertColonHost(cssText);
  23984. cssText = this._convertColonHostContext(cssText);
  23985. cssText = this._convertShadowDOMSelectors(cssText);
  23986. if (lang_1.isPresent(scopeSelector)) {
  23987. cssText = this._scopeSelectors(cssText, scopeSelector, hostSelector);
  23988. }
  23989. cssText = cssText + '\n' + unscoped;
  23990. return cssText.trim();
  23991. };
  23992. /*
  23993. * Process styles to add rules which will only apply under the polyfill
  23994. * and do not process via CSSOM. (CSSOM is destructive to rules on rare
  23995. * occasions, e.g. -webkit-calc on Safari.)
  23996. * For example, we convert this rule:
  23997. *
  23998. * @polyfill-unscoped-rule {
  23999. * content: 'menu-item';
  24000. * ... }
  24001. *
  24002. * to this:
  24003. *
  24004. * menu-item {...}
  24005. *
  24006. **/
  24007. ShadowCss.prototype._extractUnscopedRulesFromCssText = function (cssText) {
  24008. // Difference with webcomponents.js: does not handle comments
  24009. var r = '', m;
  24010. var matcher = lang_1.RegExpWrapper.matcher(_cssContentUnscopedRuleRe, cssText);
  24011. while (lang_1.isPresent(m = lang_1.RegExpMatcherWrapper.next(matcher))) {
  24012. var rule = m[0];
  24013. rule = lang_1.StringWrapper.replace(rule, m[2], '');
  24014. rule = lang_1.StringWrapper.replace(rule, m[1], m[3]);
  24015. r += rule + '\n\n';
  24016. }
  24017. return r;
  24018. };
  24019. /*
  24020. * convert a rule like :host(.foo) > .bar { }
  24021. *
  24022. * to
  24023. *
  24024. * scopeName.foo > .bar
  24025. */
  24026. ShadowCss.prototype._convertColonHost = function (cssText) {
  24027. return this._convertColonRule(cssText, _cssColonHostRe, this._colonHostPartReplacer);
  24028. };
  24029. /*
  24030. * convert a rule like :host-context(.foo) > .bar { }
  24031. *
  24032. * to
  24033. *
  24034. * scopeName.foo > .bar, .foo scopeName > .bar { }
  24035. *
  24036. * and
  24037. *
  24038. * :host-context(.foo:host) .bar { ... }
  24039. *
  24040. * to
  24041. *
  24042. * scopeName.foo .bar { ... }
  24043. */
  24044. ShadowCss.prototype._convertColonHostContext = function (cssText) {
  24045. return this._convertColonRule(cssText, _cssColonHostContextRe, this._colonHostContextPartReplacer);
  24046. };
  24047. ShadowCss.prototype._convertColonRule = function (cssText, regExp, partReplacer) {
  24048. // p1 = :host, p2 = contents of (), p3 rest of rule
  24049. return lang_1.StringWrapper.replaceAllMapped(cssText, regExp, function (m) {
  24050. if (lang_1.isPresent(m[2])) {
  24051. var parts = m[2].split(','), r = [];
  24052. for (var i = 0; i < parts.length; i++) {
  24053. var p = parts[i];
  24054. if (lang_1.isBlank(p))
  24055. break;
  24056. p = p.trim();
  24057. r.push(partReplacer(_polyfillHostNoCombinator, p, m[3]));
  24058. }
  24059. return r.join(',');
  24060. }
  24061. else {
  24062. return _polyfillHostNoCombinator + m[3];
  24063. }
  24064. });
  24065. };
  24066. ShadowCss.prototype._colonHostContextPartReplacer = function (host, part, suffix) {
  24067. if (lang_1.StringWrapper.contains(part, _polyfillHost)) {
  24068. return this._colonHostPartReplacer(host, part, suffix);
  24069. }
  24070. else {
  24071. return host + part + suffix + ', ' + part + ' ' + host + suffix;
  24072. }
  24073. };
  24074. ShadowCss.prototype._colonHostPartReplacer = function (host, part, suffix) {
  24075. return host + lang_1.StringWrapper.replace(part, _polyfillHost, '') + suffix;
  24076. };
  24077. /*
  24078. * Convert combinators like ::shadow and pseudo-elements like ::content
  24079. * by replacing with space.
  24080. */
  24081. ShadowCss.prototype._convertShadowDOMSelectors = function (cssText) {
  24082. for (var i = 0; i < _shadowDOMSelectorsRe.length; i++) {
  24083. cssText = lang_1.StringWrapper.replaceAll(cssText, _shadowDOMSelectorsRe[i], ' ');
  24084. }
  24085. return cssText;
  24086. };
  24087. // change a selector like 'div' to 'name div'
  24088. ShadowCss.prototype._scopeSelectors = function (cssText, scopeSelector, hostSelector) {
  24089. var _this = this;
  24090. return processRules(cssText, function (rule) {
  24091. var selector = rule.selector;
  24092. var content = rule.content;
  24093. if (rule.selector[0] != '@' || rule.selector.startsWith('@page')) {
  24094. selector =
  24095. _this._scopeSelector(rule.selector, scopeSelector, hostSelector, _this.strictStyling);
  24096. }
  24097. else if (rule.selector.startsWith('@media')) {
  24098. content = _this._scopeSelectors(rule.content, scopeSelector, hostSelector);
  24099. }
  24100. return new CssRule(selector, content);
  24101. });
  24102. };
  24103. ShadowCss.prototype._scopeSelector = function (selector, scopeSelector, hostSelector, strict) {
  24104. var r = [], parts = selector.split(',');
  24105. for (var i = 0; i < parts.length; i++) {
  24106. var p = parts[i];
  24107. p = p.trim();
  24108. if (this._selectorNeedsScoping(p, scopeSelector)) {
  24109. p = strict && !lang_1.StringWrapper.contains(p, _polyfillHostNoCombinator) ?
  24110. this._applyStrictSelectorScope(p, scopeSelector) :
  24111. this._applySelectorScope(p, scopeSelector, hostSelector);
  24112. }
  24113. r.push(p);
  24114. }
  24115. return r.join(', ');
  24116. };
  24117. ShadowCss.prototype._selectorNeedsScoping = function (selector, scopeSelector) {
  24118. var re = this._makeScopeMatcher(scopeSelector);
  24119. return !lang_1.isPresent(lang_1.RegExpWrapper.firstMatch(re, selector));
  24120. };
  24121. ShadowCss.prototype._makeScopeMatcher = function (scopeSelector) {
  24122. var lre = /\[/g;
  24123. var rre = /\]/g;
  24124. scopeSelector = lang_1.StringWrapper.replaceAll(scopeSelector, lre, '\\[');
  24125. scopeSelector = lang_1.StringWrapper.replaceAll(scopeSelector, rre, '\\]');
  24126. return lang_1.RegExpWrapper.create('^(' + scopeSelector + ')' + _selectorReSuffix, 'm');
  24127. };
  24128. ShadowCss.prototype._applySelectorScope = function (selector, scopeSelector, hostSelector) {
  24129. // Difference from webcomponentsjs: scopeSelector could not be an array
  24130. return this._applySimpleSelectorScope(selector, scopeSelector, hostSelector);
  24131. };
  24132. // scope via name and [is=name]
  24133. ShadowCss.prototype._applySimpleSelectorScope = function (selector, scopeSelector, hostSelector) {
  24134. if (lang_1.isPresent(lang_1.RegExpWrapper.firstMatch(_polyfillHostRe, selector))) {
  24135. var replaceBy = this.strictStyling ? "[" + hostSelector + "]" : scopeSelector;
  24136. selector = lang_1.StringWrapper.replace(selector, _polyfillHostNoCombinator, replaceBy);
  24137. return lang_1.StringWrapper.replaceAll(selector, _polyfillHostRe, replaceBy + ' ');
  24138. }
  24139. else {
  24140. return scopeSelector + ' ' + selector;
  24141. }
  24142. };
  24143. // return a selector with [name] suffix on each simple selector
  24144. // e.g. .foo.bar > .zot becomes .foo[name].bar[name] > .zot[name] /** @internal */
  24145. ShadowCss.prototype._applyStrictSelectorScope = function (selector, scopeSelector) {
  24146. var isRe = /\[is=([^\]]*)\]/g;
  24147. scopeSelector = lang_1.StringWrapper.replaceAllMapped(scopeSelector, isRe, function (m) { return m[1]; });
  24148. var splits = [' ', '>', '+', '~'], scoped = selector, attrName = '[' + scopeSelector + ']';
  24149. for (var i = 0; i < splits.length; i++) {
  24150. var sep = splits[i];
  24151. var parts = scoped.split(sep);
  24152. scoped = parts.map(function (p) {
  24153. // remove :host since it should be unnecessary
  24154. var t = lang_1.StringWrapper.replaceAll(p.trim(), _polyfillHostRe, '');
  24155. if (t.length > 0 && !collection_1.ListWrapper.contains(splits, t) &&
  24156. !lang_1.StringWrapper.contains(t, attrName)) {
  24157. var re = /([^:]*)(:*)(.*)/g;
  24158. var m = lang_1.RegExpWrapper.firstMatch(re, t);
  24159. if (lang_1.isPresent(m)) {
  24160. p = m[1] + attrName + m[2] + m[3];
  24161. }
  24162. }
  24163. return p;
  24164. })
  24165. .join(sep);
  24166. }
  24167. return scoped;
  24168. };
  24169. ShadowCss.prototype._insertPolyfillHostInCssText = function (selector) {
  24170. selector = lang_1.StringWrapper.replaceAll(selector, _colonHostContextRe, _polyfillHostContext);
  24171. selector = lang_1.StringWrapper.replaceAll(selector, _colonHostRe, _polyfillHost);
  24172. return selector;
  24173. };
  24174. return ShadowCss;
  24175. })();
  24176. exports.ShadowCss = ShadowCss;
  24177. var _cssContentNextSelectorRe = /polyfill-next-selector[^}]*content:[\s]*?['"](.*?)['"][;\s]*}([^{]*?){/gim;
  24178. var _cssContentRuleRe = /(polyfill-rule)[^}]*(content:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim;
  24179. var _cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim;
  24180. var _polyfillHost = '-shadowcsshost';
  24181. // note: :host-context pre-processed to -shadowcsshostcontext.
  24182. var _polyfillHostContext = '-shadowcsscontext';
  24183. var _parenSuffix = ')(?:\\((' +
  24184. '(?:\\([^)(]*\\)|[^)(]*)+?' +
  24185. ')\\))?([^,{]*)';
  24186. var _cssColonHostRe = lang_1.RegExpWrapper.create('(' + _polyfillHost + _parenSuffix, 'im');
  24187. var _cssColonHostContextRe = lang_1.RegExpWrapper.create('(' + _polyfillHostContext + _parenSuffix, 'im');
  24188. var _polyfillHostNoCombinator = _polyfillHost + '-no-combinator';
  24189. var _shadowDOMSelectorsRe = [
  24190. />>>/g,
  24191. /::shadow/g,
  24192. /::content/g,
  24193. // Deprecated selectors
  24194. // TODO(vicb): see https://github.com/angular/clang-format/issues/16
  24195. // clang-format off
  24196. /\/deep\//g,
  24197. /\/shadow-deep\//g,
  24198. /\/shadow\//g,
  24199. ];
  24200. var _selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$';
  24201. var _polyfillHostRe = lang_1.RegExpWrapper.create(_polyfillHost, 'im');
  24202. var _colonHostRe = /:host/gim;
  24203. var _colonHostContextRe = /:host-context/gim;
  24204. var _commentRe = /\/\*[\s\S]*?\*\//g;
  24205. function stripComments(input) {
  24206. return lang_1.StringWrapper.replaceAllMapped(input, _commentRe, function (_) { return ''; });
  24207. }
  24208. var _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
  24209. var _curlyRe = /([{}])/g;
  24210. var OPEN_CURLY = '{';
  24211. var CLOSE_CURLY = '}';
  24212. var BLOCK_PLACEHOLDER = '%BLOCK%';
  24213. var CssRule = (function () {
  24214. function CssRule(selector, content) {
  24215. this.selector = selector;
  24216. this.content = content;
  24217. }
  24218. return CssRule;
  24219. })();
  24220. exports.CssRule = CssRule;
  24221. function processRules(input, ruleCallback) {
  24222. var inputWithEscapedBlocks = escapeBlocks(input);
  24223. var nextBlockIndex = 0;
  24224. return lang_1.StringWrapper.replaceAllMapped(inputWithEscapedBlocks.escapedString, _ruleRe, function (m) {
  24225. var selector = m[2];
  24226. var content = '';
  24227. var suffix = m[4];
  24228. var contentPrefix = '';
  24229. if (lang_1.isPresent(m[4]) && m[4].startsWith('{' + BLOCK_PLACEHOLDER)) {
  24230. content = inputWithEscapedBlocks.blocks[nextBlockIndex++];
  24231. suffix = m[4].substring(BLOCK_PLACEHOLDER.length + 1);
  24232. contentPrefix = '{';
  24233. }
  24234. var rule = ruleCallback(new CssRule(selector, content));
  24235. return "" + m[1] + rule.selector + m[3] + contentPrefix + rule.content + suffix;
  24236. });
  24237. }
  24238. exports.processRules = processRules;
  24239. var StringWithEscapedBlocks = (function () {
  24240. function StringWithEscapedBlocks(escapedString, blocks) {
  24241. this.escapedString = escapedString;
  24242. this.blocks = blocks;
  24243. }
  24244. return StringWithEscapedBlocks;
  24245. })();
  24246. function escapeBlocks(input) {
  24247. var inputParts = lang_1.StringWrapper.split(input, _curlyRe);
  24248. var resultParts = [];
  24249. var escapedBlocks = [];
  24250. var bracketCount = 0;
  24251. var currentBlockParts = [];
  24252. for (var partIndex = 0; partIndex < inputParts.length; partIndex++) {
  24253. var part = inputParts[partIndex];
  24254. if (part == CLOSE_CURLY) {
  24255. bracketCount--;
  24256. }
  24257. if (bracketCount > 0) {
  24258. currentBlockParts.push(part);
  24259. }
  24260. else {
  24261. if (currentBlockParts.length > 0) {
  24262. escapedBlocks.push(currentBlockParts.join(''));
  24263. resultParts.push(BLOCK_PLACEHOLDER);
  24264. currentBlockParts = [];
  24265. }
  24266. resultParts.push(part);
  24267. }
  24268. if (part == OPEN_CURLY) {
  24269. bracketCount++;
  24270. }
  24271. }
  24272. if (currentBlockParts.length > 0) {
  24273. escapedBlocks.push(currentBlockParts.join(''));
  24274. resultParts.push(BLOCK_PLACEHOLDER);
  24275. }
  24276. return new StringWithEscapedBlocks(resultParts.join(''), escapedBlocks);
  24277. }
  24278. /***/ },
  24279. /* 163 */
  24280. /***/ function(module, exports, __webpack_require__) {
  24281. // Some of the code comes from WebComponents.JS
  24282. // https://github.com/webcomponents/webcomponentsjs/blob/master/src/HTMLImports/path.js
  24283. var lang_1 = __webpack_require__(5);
  24284. var StyleWithImports = (function () {
  24285. function StyleWithImports(style, styleUrls) {
  24286. this.style = style;
  24287. this.styleUrls = styleUrls;
  24288. }
  24289. return StyleWithImports;
  24290. })();
  24291. exports.StyleWithImports = StyleWithImports;
  24292. function isStyleUrlResolvable(url) {
  24293. if (lang_1.isBlank(url) || url.length === 0 || url[0] == '/')
  24294. return false;
  24295. var schemeMatch = lang_1.RegExpWrapper.firstMatch(_urlWithSchemaRe, url);
  24296. return lang_1.isBlank(schemeMatch) || schemeMatch[1] == 'package' || schemeMatch[1] == 'asset';
  24297. }
  24298. exports.isStyleUrlResolvable = isStyleUrlResolvable;
  24299. /**
  24300. * Rewrites stylesheets by resolving and removing the @import urls that
  24301. * are either relative or don't have a `package:` scheme
  24302. */
  24303. function extractStyleUrls(resolver, baseUrl, cssText) {
  24304. var foundUrls = [];
  24305. var modifiedCssText = lang_1.StringWrapper.replaceAllMapped(cssText, _cssImportRe, function (m) {
  24306. var url = lang_1.isPresent(m[1]) ? m[1] : m[2];
  24307. if (!isStyleUrlResolvable(url)) {
  24308. // Do not attempt to resolve non-package absolute URLs with URI scheme
  24309. return m[0];
  24310. }
  24311. foundUrls.push(resolver.resolve(baseUrl, url));
  24312. return '';
  24313. });
  24314. return new StyleWithImports(modifiedCssText, foundUrls);
  24315. }
  24316. exports.extractStyleUrls = extractStyleUrls;
  24317. var _cssImportRe = /@import\s+(?:url\()?\s*(?:(?:['"]([^'"]*))|([^;\)\s]*))[^;]*;?/g;
  24318. // TODO: can't use /^[^:/?#.]+:/g due to clang-format bug:
  24319. // https://github.com/angular/angular/issues/4596
  24320. var _urlWithSchemaRe = /^([a-zA-Z\-\+\.]+):/g;
  24321. /***/ },
  24322. /* 164 */
  24323. /***/ function(module, exports, __webpack_require__) {
  24324. var lang_1 = __webpack_require__(5);
  24325. var view_1 = __webpack_require__(165);
  24326. var metadata_1 = __webpack_require__(3);
  24327. var collection_1 = __webpack_require__(12);
  24328. function encapsulateStyles(componentTemplate) {
  24329. var processedStyles = componentTemplate.styles;
  24330. if (componentTemplate.encapsulation === metadata_1.ViewEncapsulation.Emulated) {
  24331. processedStyles = collection_1.ListWrapper.createFixedSize(componentTemplate.styles.length);
  24332. for (var i = 0; i < componentTemplate.styles.length; i++) {
  24333. processedStyles[i] = lang_1.StringWrapper.replaceAll(componentTemplate.styles[i], COMPONENT_REGEX, componentTemplate.shortId);
  24334. }
  24335. }
  24336. return processedStyles;
  24337. }
  24338. exports.encapsulateStyles = encapsulateStyles;
  24339. function createRenderView(componentTemplate, cmds, inplaceElement, nodeFactory) {
  24340. var view;
  24341. var eventDispatcher = function (boundElementIndex, eventName, event) {
  24342. return view.dispatchRenderEvent(boundElementIndex, eventName, event);
  24343. };
  24344. var context = new BuildContext(eventDispatcher, nodeFactory, inplaceElement);
  24345. context.build(componentTemplate, cmds);
  24346. var fragments = [];
  24347. for (var i = 0; i < context.fragments.length; i++) {
  24348. fragments.push(new view_1.DefaultRenderFragmentRef(context.fragments[i]));
  24349. }
  24350. view = new view_1.DefaultRenderView(fragments, context.boundTextNodes, context.boundElements, context.nativeShadowRoots, context.globalEventAdders, context.rootContentInsertionPoints);
  24351. return view;
  24352. }
  24353. exports.createRenderView = createRenderView;
  24354. var BuildContext = (function () {
  24355. function BuildContext(_eventDispatcher, factory, _inplaceElement) {
  24356. this._eventDispatcher = _eventDispatcher;
  24357. this.factory = factory;
  24358. this._inplaceElement = _inplaceElement;
  24359. this._builders = [];
  24360. this.globalEventAdders = [];
  24361. this.boundElements = [];
  24362. this.boundTextNodes = [];
  24363. this.nativeShadowRoots = [];
  24364. this.fragments = [];
  24365. this.rootContentInsertionPoints = [];
  24366. this.componentCount = 0;
  24367. this.isHost = lang_1.isPresent((_inplaceElement));
  24368. }
  24369. BuildContext.prototype.build = function (template, cmds) {
  24370. this.enqueueRootBuilder(template, cmds);
  24371. this._build(this._builders[0]);
  24372. };
  24373. BuildContext.prototype._build = function (builder) {
  24374. this._builders = [];
  24375. builder.build(this);
  24376. var enqueuedBuilders = this._builders;
  24377. for (var i = 0; i < enqueuedBuilders.length; i++) {
  24378. this._build(enqueuedBuilders[i]);
  24379. }
  24380. };
  24381. BuildContext.prototype.enqueueComponentBuilder = function (component) {
  24382. this.componentCount++;
  24383. this._builders.push(new RenderViewBuilder(component, null, component.template, component.template.commands));
  24384. };
  24385. BuildContext.prototype.enqueueFragmentBuilder = function (parentComponent, parentTemplate, commands) {
  24386. var rootNodes = [];
  24387. this.fragments.push(rootNodes);
  24388. this._builders.push(new RenderViewBuilder(parentComponent, rootNodes, parentTemplate, commands));
  24389. };
  24390. BuildContext.prototype.enqueueRootBuilder = function (template, cmds) {
  24391. var rootNodes = [];
  24392. this.fragments.push(rootNodes);
  24393. this._builders.push(new RenderViewBuilder(null, rootNodes, template, cmds));
  24394. };
  24395. BuildContext.prototype.consumeInplaceElement = function () {
  24396. var result = this._inplaceElement;
  24397. this._inplaceElement = null;
  24398. return result;
  24399. };
  24400. BuildContext.prototype.addEventListener = function (boundElementIndex, target, eventName) {
  24401. if (lang_1.isPresent(target)) {
  24402. var handler = createEventHandler(boundElementIndex, target + ":" + eventName, this._eventDispatcher);
  24403. this.globalEventAdders.push(createGlobalEventAdder(target, eventName, handler, this.factory));
  24404. }
  24405. else {
  24406. var handler = createEventHandler(boundElementIndex, eventName, this._eventDispatcher);
  24407. this.factory.on(this.boundElements[boundElementIndex], eventName, handler);
  24408. }
  24409. };
  24410. return BuildContext;
  24411. })();
  24412. function createEventHandler(boundElementIndex, eventName, eventDispatcher) {
  24413. return function ($event) { return eventDispatcher(boundElementIndex, eventName, $event); };
  24414. }
  24415. function createGlobalEventAdder(target, eventName, eventHandler, nodeFactory) {
  24416. return function () { return nodeFactory.globalOn(target, eventName, eventHandler); };
  24417. }
  24418. var RenderViewBuilder = (function () {
  24419. function RenderViewBuilder(parentComponent, fragmentRootNodes, template, cmds) {
  24420. this.parentComponent = parentComponent;
  24421. this.fragmentRootNodes = fragmentRootNodes;
  24422. this.template = template;
  24423. this.cmds = cmds;
  24424. var rootNodesParent = lang_1.isPresent(fragmentRootNodes) ? null : parentComponent.shadowRoot;
  24425. this.parentStack = [rootNodesParent];
  24426. }
  24427. RenderViewBuilder.prototype.build = function (context) {
  24428. var cmds = this.cmds;
  24429. for (var i = 0; i < cmds.length; i++) {
  24430. cmds[i].visit(this, context);
  24431. }
  24432. };
  24433. Object.defineProperty(RenderViewBuilder.prototype, "parent", {
  24434. get: function () { return this.parentStack[this.parentStack.length - 1]; },
  24435. enumerable: true,
  24436. configurable: true
  24437. });
  24438. RenderViewBuilder.prototype.visitText = function (cmd, context) {
  24439. var text = context.factory.createText(cmd.value);
  24440. this._addChild(text, cmd.ngContentIndex, context);
  24441. if (cmd.isBound) {
  24442. context.boundTextNodes.push(text);
  24443. }
  24444. return null;
  24445. };
  24446. RenderViewBuilder.prototype.visitNgContent = function (cmd, context) {
  24447. if (lang_1.isPresent(this.parentComponent)) {
  24448. if (this.parentComponent.isRoot) {
  24449. var insertionPoint = context.factory.createRootContentInsertionPoint();
  24450. if (this.parent instanceof Component) {
  24451. context.factory.appendChild(this.parent.shadowRoot, insertionPoint);
  24452. }
  24453. else {
  24454. context.factory.appendChild(this.parent, insertionPoint);
  24455. }
  24456. context.rootContentInsertionPoints.push(insertionPoint);
  24457. }
  24458. else {
  24459. var projectedNodes = this.parentComponent.project(cmd.index);
  24460. for (var i = 0; i < projectedNodes.length; i++) {
  24461. var node = projectedNodes[i];
  24462. this._addChild(node, cmd.ngContentIndex, context);
  24463. }
  24464. }
  24465. }
  24466. return null;
  24467. };
  24468. RenderViewBuilder.prototype.visitBeginElement = function (cmd, context) {
  24469. this.parentStack.push(this._beginElement(cmd, context, null));
  24470. return null;
  24471. };
  24472. RenderViewBuilder.prototype.visitEndElement = function (context) {
  24473. this._endElement();
  24474. return null;
  24475. };
  24476. RenderViewBuilder.prototype.visitBeginComponent = function (cmd, context) {
  24477. var templateId = cmd.templateId;
  24478. var tpl = context.factory.resolveComponentTemplate(templateId);
  24479. var el = this._beginElement(cmd, context, tpl);
  24480. var root = el;
  24481. if (tpl.encapsulation === metadata_1.ViewEncapsulation.Native) {
  24482. root = context.factory.createShadowRoot(el, templateId);
  24483. context.nativeShadowRoots.push(root);
  24484. }
  24485. var isRoot = context.componentCount === 0 && context.isHost;
  24486. var component = new Component(el, root, isRoot, tpl);
  24487. context.enqueueComponentBuilder(component);
  24488. this.parentStack.push(component);
  24489. return null;
  24490. };
  24491. RenderViewBuilder.prototype.visitEndComponent = function (context) {
  24492. this._endElement();
  24493. return null;
  24494. };
  24495. RenderViewBuilder.prototype.visitEmbeddedTemplate = function (cmd, context) {
  24496. var el = context.factory.createTemplateAnchor(cmd.attrNameAndValues);
  24497. this._addChild(el, cmd.ngContentIndex, context);
  24498. context.boundElements.push(el);
  24499. if (cmd.isMerged) {
  24500. context.enqueueFragmentBuilder(this.parentComponent, this.template, cmd.children);
  24501. }
  24502. return null;
  24503. };
  24504. RenderViewBuilder.prototype._beginElement = function (cmd, context, componentTemplate) {
  24505. var el = context.consumeInplaceElement();
  24506. var attrNameAndValues = cmd.attrNameAndValues;
  24507. var templateEmulatedEncapsulation = this.template.encapsulation === metadata_1.ViewEncapsulation.Emulated;
  24508. var componentEmulatedEncapsulation = lang_1.isPresent(componentTemplate) &&
  24509. componentTemplate.encapsulation === metadata_1.ViewEncapsulation.Emulated;
  24510. var newAttrLength = attrNameAndValues.length + (templateEmulatedEncapsulation ? 2 : 0) +
  24511. (componentEmulatedEncapsulation ? 2 : 0);
  24512. if (newAttrLength > attrNameAndValues.length) {
  24513. // Note: Need to clone attrNameAndValues to make it writable!
  24514. var newAttrNameAndValues = collection_1.ListWrapper.createFixedSize(newAttrLength);
  24515. var attrIndex;
  24516. for (attrIndex = 0; attrIndex < attrNameAndValues.length; attrIndex++) {
  24517. newAttrNameAndValues[attrIndex] = attrNameAndValues[attrIndex];
  24518. }
  24519. if (templateEmulatedEncapsulation) {
  24520. newAttrNameAndValues[attrIndex++] = _shimContentAttribute(this.template.shortId);
  24521. newAttrNameAndValues[attrIndex++] = '';
  24522. }
  24523. if (componentEmulatedEncapsulation) {
  24524. newAttrNameAndValues[attrIndex++] = _shimHostAttribute(componentTemplate.shortId);
  24525. newAttrNameAndValues[attrIndex++] = '';
  24526. }
  24527. attrNameAndValues = newAttrNameAndValues;
  24528. }
  24529. if (lang_1.isPresent(el)) {
  24530. context.factory.mergeElement(el, attrNameAndValues);
  24531. this.fragmentRootNodes.push(el);
  24532. }
  24533. else {
  24534. el = context.factory.createElement(cmd.name, attrNameAndValues);
  24535. this._addChild(el, cmd.ngContentIndex, context);
  24536. }
  24537. if (cmd.isBound) {
  24538. var boundElementIndex = context.boundElements.length;
  24539. context.boundElements.push(el);
  24540. for (var i = 0; i < cmd.eventTargetAndNames.length; i += 2) {
  24541. var target = cmd.eventTargetAndNames[i];
  24542. var eventName = cmd.eventTargetAndNames[i + 1];
  24543. context.addEventListener(boundElementIndex, target, eventName);
  24544. }
  24545. }
  24546. return el;
  24547. };
  24548. RenderViewBuilder.prototype._endElement = function () { this.parentStack.pop(); };
  24549. RenderViewBuilder.prototype._addChild = function (node, ngContentIndex, context) {
  24550. var parent = this.parent;
  24551. if (lang_1.isPresent(parent)) {
  24552. if (parent instanceof Component) {
  24553. parent.addContentNode(ngContentIndex, node, context);
  24554. }
  24555. else {
  24556. context.factory.appendChild(parent, node);
  24557. }
  24558. }
  24559. else {
  24560. this.fragmentRootNodes.push(node);
  24561. }
  24562. };
  24563. return RenderViewBuilder;
  24564. })();
  24565. var Component = (function () {
  24566. function Component(hostElement, shadowRoot, isRoot, template) {
  24567. this.hostElement = hostElement;
  24568. this.shadowRoot = shadowRoot;
  24569. this.isRoot = isRoot;
  24570. this.template = template;
  24571. this.contentNodesByNgContentIndex = [];
  24572. }
  24573. Component.prototype.addContentNode = function (ngContentIndex, node, context) {
  24574. if (lang_1.isBlank(ngContentIndex)) {
  24575. if (this.template.encapsulation === metadata_1.ViewEncapsulation.Native) {
  24576. context.factory.appendChild(this.hostElement, node);
  24577. }
  24578. }
  24579. else {
  24580. while (this.contentNodesByNgContentIndex.length <= ngContentIndex) {
  24581. this.contentNodesByNgContentIndex.push([]);
  24582. }
  24583. this.contentNodesByNgContentIndex[ngContentIndex].push(node);
  24584. }
  24585. };
  24586. Component.prototype.project = function (ngContentIndex) {
  24587. return ngContentIndex < this.contentNodesByNgContentIndex.length ?
  24588. this.contentNodesByNgContentIndex[ngContentIndex] :
  24589. [];
  24590. };
  24591. return Component;
  24592. })();
  24593. var COMPONENT_REGEX = /%COMP%/g;
  24594. exports.COMPONENT_VARIABLE = '%COMP%';
  24595. exports.HOST_ATTR = "_nghost-" + exports.COMPONENT_VARIABLE;
  24596. exports.CONTENT_ATTR = "_ngcontent-" + exports.COMPONENT_VARIABLE;
  24597. function _shimContentAttribute(componentShortId) {
  24598. return lang_1.StringWrapper.replaceAll(exports.CONTENT_ATTR, COMPONENT_REGEX, componentShortId);
  24599. }
  24600. function _shimHostAttribute(componentShortId) {
  24601. return lang_1.StringWrapper.replaceAll(exports.HOST_ATTR, COMPONENT_REGEX, componentShortId);
  24602. }
  24603. /***/ },
  24604. /* 165 */
  24605. /***/ function(module, exports, __webpack_require__) {
  24606. var __extends = (this && this.__extends) || function (d, b) {
  24607. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  24608. function __() { this.constructor = d; }
  24609. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24610. };
  24611. var exceptions_1 = __webpack_require__(14);
  24612. var collection_1 = __webpack_require__(12);
  24613. var lang_1 = __webpack_require__(5);
  24614. var api_1 = __webpack_require__(72);
  24615. var DefaultProtoViewRef = (function (_super) {
  24616. __extends(DefaultProtoViewRef, _super);
  24617. function DefaultProtoViewRef(template, cmds) {
  24618. _super.call(this);
  24619. this.template = template;
  24620. this.cmds = cmds;
  24621. }
  24622. return DefaultProtoViewRef;
  24623. })(api_1.RenderProtoViewRef);
  24624. exports.DefaultProtoViewRef = DefaultProtoViewRef;
  24625. var DefaultRenderFragmentRef = (function (_super) {
  24626. __extends(DefaultRenderFragmentRef, _super);
  24627. function DefaultRenderFragmentRef(nodes) {
  24628. _super.call(this);
  24629. this.nodes = nodes;
  24630. }
  24631. return DefaultRenderFragmentRef;
  24632. })(api_1.RenderFragmentRef);
  24633. exports.DefaultRenderFragmentRef = DefaultRenderFragmentRef;
  24634. var DefaultRenderView = (function (_super) {
  24635. __extends(DefaultRenderView, _super);
  24636. function DefaultRenderView(fragments, boundTextNodes, boundElements, nativeShadowRoots, globalEventAdders, rootContentInsertionPoints) {
  24637. _super.call(this);
  24638. this.fragments = fragments;
  24639. this.boundTextNodes = boundTextNodes;
  24640. this.boundElements = boundElements;
  24641. this.nativeShadowRoots = nativeShadowRoots;
  24642. this.globalEventAdders = globalEventAdders;
  24643. this.rootContentInsertionPoints = rootContentInsertionPoints;
  24644. this.hydrated = false;
  24645. this.eventDispatcher = null;
  24646. this.globalEventRemovers = null;
  24647. }
  24648. DefaultRenderView.prototype.hydrate = function () {
  24649. if (this.hydrated)
  24650. throw new exceptions_1.BaseException('The view is already hydrated.');
  24651. this.hydrated = true;
  24652. this.globalEventRemovers = collection_1.ListWrapper.createFixedSize(this.globalEventAdders.length);
  24653. for (var i = 0; i < this.globalEventAdders.length; i++) {
  24654. this.globalEventRemovers[i] = this.globalEventAdders[i]();
  24655. }
  24656. };
  24657. DefaultRenderView.prototype.dehydrate = function () {
  24658. if (!this.hydrated)
  24659. throw new exceptions_1.BaseException('The view is already dehydrated.');
  24660. for (var i = 0; i < this.globalEventRemovers.length; i++) {
  24661. this.globalEventRemovers[i]();
  24662. }
  24663. this.globalEventRemovers = null;
  24664. this.hydrated = false;
  24665. };
  24666. DefaultRenderView.prototype.setEventDispatcher = function (dispatcher) { this.eventDispatcher = dispatcher; };
  24667. DefaultRenderView.prototype.dispatchRenderEvent = function (boundElementIndex, eventName, event) {
  24668. var allowDefaultBehavior = true;
  24669. if (lang_1.isPresent(this.eventDispatcher)) {
  24670. var locals = new collection_1.Map();
  24671. locals.set('$event', event);
  24672. allowDefaultBehavior =
  24673. this.eventDispatcher.dispatchRenderEvent(boundElementIndex, eventName, locals);
  24674. }
  24675. return allowDefaultBehavior;
  24676. };
  24677. return DefaultRenderView;
  24678. })(api_1.RenderViewRef);
  24679. exports.DefaultRenderView = DefaultRenderView;
  24680. /***/ },
  24681. /* 166 */
  24682. /***/ function(module, exports, __webpack_require__) {
  24683. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  24684. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  24685. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  24686. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  24687. return c > 3 && r && Object.defineProperty(target, key, r), r;
  24688. };
  24689. var __metadata = (this && this.__metadata) || function (k, v) {
  24690. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  24691. };
  24692. var lang_1 = __webpack_require__(5);
  24693. var collection_1 = __webpack_require__(12);
  24694. var template_commands_1 = __webpack_require__(96);
  24695. var template_ast_1 = __webpack_require__(159);
  24696. var source_module_1 = __webpack_require__(156);
  24697. var util_1 = __webpack_require__(155);
  24698. var di_1 = __webpack_require__(6);
  24699. exports.TEMPLATE_COMMANDS_MODULE_REF = source_module_1.moduleRef("package:angular2/src/core/linker/template_commands" + util_1.MODULE_SUFFIX);
  24700. var IMPLICIT_TEMPLATE_VAR = '\$implicit';
  24701. var CLASS_ATTR = 'class';
  24702. var STYLE_ATTR = 'style';
  24703. var CommandCompiler = (function () {
  24704. function CommandCompiler() {
  24705. }
  24706. CommandCompiler.prototype.compileComponentRuntime = function (component, template, changeDetectorFactories, componentTemplateFactory) {
  24707. var visitor = new CommandBuilderVisitor(new RuntimeCommandFactory(component, componentTemplateFactory, changeDetectorFactories), 0);
  24708. template_ast_1.templateVisitAll(visitor, template);
  24709. return visitor.result;
  24710. };
  24711. CommandCompiler.prototype.compileComponentCodeGen = function (component, template, changeDetectorFactoryExpressions, componentTemplateFactory) {
  24712. var visitor = new CommandBuilderVisitor(new CodegenCommandFactory(component, componentTemplateFactory, changeDetectorFactoryExpressions), 0);
  24713. template_ast_1.templateVisitAll(visitor, template);
  24714. return new source_module_1.SourceExpression([], codeGenArray(visitor.result));
  24715. };
  24716. CommandCompiler = __decorate([
  24717. di_1.Injectable(),
  24718. __metadata('design:paramtypes', [])
  24719. ], CommandCompiler);
  24720. return CommandCompiler;
  24721. })();
  24722. exports.CommandCompiler = CommandCompiler;
  24723. var RuntimeCommandFactory = (function () {
  24724. function RuntimeCommandFactory(component, componentTemplateFactory, changeDetectorFactories) {
  24725. this.component = component;
  24726. this.componentTemplateFactory = componentTemplateFactory;
  24727. this.changeDetectorFactories = changeDetectorFactories;
  24728. }
  24729. RuntimeCommandFactory.prototype._mapDirectives = function (directives) {
  24730. return directives.map(function (directive) { return directive.type.runtime; });
  24731. };
  24732. RuntimeCommandFactory.prototype.createText = function (value, isBound, ngContentIndex) {
  24733. return new template_commands_1.TextCmd(value, isBound, ngContentIndex);
  24734. };
  24735. RuntimeCommandFactory.prototype.createNgContent = function (index, ngContentIndex) {
  24736. return new template_commands_1.NgContentCmd(index, ngContentIndex);
  24737. };
  24738. RuntimeCommandFactory.prototype.createBeginElement = function (name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, isBound, ngContentIndex) {
  24739. return new template_commands_1.BeginElementCmd(name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, this._mapDirectives(directives), isBound, ngContentIndex);
  24740. };
  24741. RuntimeCommandFactory.prototype.createEndElement = function () { return new template_commands_1.EndElementCmd(); };
  24742. RuntimeCommandFactory.prototype.createBeginComponent = function (name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, encapsulation, ngContentIndex) {
  24743. var nestedTemplateAccessor = this.componentTemplateFactory(directives[0]);
  24744. return new template_commands_1.BeginComponentCmd(name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, this._mapDirectives(directives), encapsulation, ngContentIndex, nestedTemplateAccessor);
  24745. };
  24746. RuntimeCommandFactory.prototype.createEndComponent = function () { return new template_commands_1.EndComponentCmd(); };
  24747. RuntimeCommandFactory.prototype.createEmbeddedTemplate = function (embeddedTemplateIndex, attrNameAndValues, variableNameAndValues, directives, isMerged, ngContentIndex, children) {
  24748. return new template_commands_1.EmbeddedTemplateCmd(attrNameAndValues, variableNameAndValues, this._mapDirectives(directives), isMerged, ngContentIndex, this.changeDetectorFactories[embeddedTemplateIndex], children);
  24749. };
  24750. return RuntimeCommandFactory;
  24751. })();
  24752. var CodegenCommandFactory = (function () {
  24753. function CodegenCommandFactory(component, componentTemplateFactory, changeDetectorFactoryExpressions) {
  24754. this.component = component;
  24755. this.componentTemplateFactory = componentTemplateFactory;
  24756. this.changeDetectorFactoryExpressions = changeDetectorFactoryExpressions;
  24757. }
  24758. CodegenCommandFactory.prototype.createText = function (value, isBound, ngContentIndex) {
  24759. return new Expression(util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'TextCmd') + "(" + util_1.escapeSingleQuoteString(value) + ", " + isBound + ", " + ngContentIndex + ")");
  24760. };
  24761. CodegenCommandFactory.prototype.createNgContent = function (index, ngContentIndex) {
  24762. return new Expression(util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'NgContentCmd') + "(" + index + ", " + ngContentIndex + ")");
  24763. };
  24764. CodegenCommandFactory.prototype.createBeginElement = function (name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, isBound, ngContentIndex) {
  24765. var attrsExpression = codeGenArray(attrNameAndValues);
  24766. return new Expression((util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'BeginElementCmd') + "(" + util_1.escapeSingleQuoteString(name) + ", " + attrsExpression + ", ") +
  24767. (codeGenArray(eventTargetAndNames) + ", " + codeGenArray(variableNameAndValues) + ", " + codeGenDirectivesArray(directives) + ", " + isBound + ", " + ngContentIndex + ")"));
  24768. };
  24769. CodegenCommandFactory.prototype.createEndElement = function () {
  24770. return new Expression(util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'EndElementCmd') + "()");
  24771. };
  24772. CodegenCommandFactory.prototype.createBeginComponent = function (name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, encapsulation, ngContentIndex) {
  24773. var attrsExpression = codeGenArray(attrNameAndValues);
  24774. return new Expression((util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'BeginComponentCmd') + "(" + util_1.escapeSingleQuoteString(name) + ", " + attrsExpression + ", ") +
  24775. (codeGenArray(eventTargetAndNames) + ", " + codeGenArray(variableNameAndValues) + ", " + codeGenDirectivesArray(directives) + ", " + codeGenViewEncapsulation(encapsulation) + ", " + ngContentIndex + ", " + this.componentTemplateFactory(directives[0]) + ")"));
  24776. };
  24777. CodegenCommandFactory.prototype.createEndComponent = function () {
  24778. return new Expression(util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'EndComponentCmd') + "()");
  24779. };
  24780. CodegenCommandFactory.prototype.createEmbeddedTemplate = function (embeddedTemplateIndex, attrNameAndValues, variableNameAndValues, directives, isMerged, ngContentIndex, children) {
  24781. return new Expression((util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'EmbeddedTemplateCmd') + "(" + codeGenArray(attrNameAndValues) + ", " + codeGenArray(variableNameAndValues) + ", ") +
  24782. (codeGenDirectivesArray(directives) + ", " + isMerged + ", " + ngContentIndex + ", " + this.changeDetectorFactoryExpressions[embeddedTemplateIndex] + ", " + codeGenArray(children) + ")"));
  24783. };
  24784. return CodegenCommandFactory;
  24785. })();
  24786. function visitAndReturnContext(visitor, asts, context) {
  24787. template_ast_1.templateVisitAll(visitor, asts, context);
  24788. return context;
  24789. }
  24790. var CommandBuilderVisitor = (function () {
  24791. function CommandBuilderVisitor(commandFactory, embeddedTemplateIndex) {
  24792. this.commandFactory = commandFactory;
  24793. this.embeddedTemplateIndex = embeddedTemplateIndex;
  24794. this.result = [];
  24795. this.transitiveNgContentCount = 0;
  24796. }
  24797. CommandBuilderVisitor.prototype._readAttrNameAndValues = function (directives, attrAsts) {
  24798. var attrs = keyValueArrayToMap(visitAndReturnContext(this, attrAsts, []));
  24799. directives.forEach(function (directiveMeta) {
  24800. collection_1.StringMapWrapper.forEach(directiveMeta.hostAttributes, function (value, name) {
  24801. var prevValue = attrs[name];
  24802. attrs[name] = lang_1.isPresent(prevValue) ? mergeAttributeValue(name, prevValue, value) : value;
  24803. });
  24804. });
  24805. return mapToKeyValueArray(attrs);
  24806. };
  24807. CommandBuilderVisitor.prototype.visitNgContent = function (ast, context) {
  24808. this.transitiveNgContentCount++;
  24809. this.result.push(this.commandFactory.createNgContent(ast.index, ast.ngContentIndex));
  24810. return null;
  24811. };
  24812. CommandBuilderVisitor.prototype.visitEmbeddedTemplate = function (ast, context) {
  24813. var _this = this;
  24814. this.embeddedTemplateIndex++;
  24815. var childVisitor = new CommandBuilderVisitor(this.commandFactory, this.embeddedTemplateIndex);
  24816. template_ast_1.templateVisitAll(childVisitor, ast.children);
  24817. var isMerged = childVisitor.transitiveNgContentCount > 0;
  24818. var variableNameAndValues = [];
  24819. ast.vars.forEach(function (varAst) {
  24820. variableNameAndValues.push(varAst.name);
  24821. variableNameAndValues.push(varAst.value.length > 0 ? varAst.value : IMPLICIT_TEMPLATE_VAR);
  24822. });
  24823. var directives = [];
  24824. collection_1.ListWrapper.forEachWithIndex(ast.directives, function (directiveAst, index) {
  24825. directiveAst.visit(_this, new DirectiveContext(index, [], [], directives));
  24826. });
  24827. this.result.push(this.commandFactory.createEmbeddedTemplate(this.embeddedTemplateIndex, this._readAttrNameAndValues(directives, ast.attrs), variableNameAndValues, directives, isMerged, ast.ngContentIndex, childVisitor.result));
  24828. this.transitiveNgContentCount += childVisitor.transitiveNgContentCount;
  24829. this.embeddedTemplateIndex = childVisitor.embeddedTemplateIndex;
  24830. return null;
  24831. };
  24832. CommandBuilderVisitor.prototype.visitElement = function (ast, context) {
  24833. var _this = this;
  24834. var component = ast.getComponent();
  24835. var eventTargetAndNames = visitAndReturnContext(this, ast.outputs, []);
  24836. var variableNameAndValues = [];
  24837. if (lang_1.isBlank(component)) {
  24838. ast.exportAsVars.forEach(function (varAst) {
  24839. variableNameAndValues.push(varAst.name);
  24840. variableNameAndValues.push(null);
  24841. });
  24842. }
  24843. var directives = [];
  24844. collection_1.ListWrapper.forEachWithIndex(ast.directives, function (directiveAst, index) {
  24845. directiveAst.visit(_this, new DirectiveContext(index, eventTargetAndNames, variableNameAndValues, directives));
  24846. });
  24847. eventTargetAndNames = removeKeyValueArrayDuplicates(eventTargetAndNames);
  24848. var attrNameAndValues = this._readAttrNameAndValues(directives, ast.attrs);
  24849. if (lang_1.isPresent(component)) {
  24850. this.result.push(this.commandFactory.createBeginComponent(ast.name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, component.template.encapsulation, ast.ngContentIndex));
  24851. template_ast_1.templateVisitAll(this, ast.children);
  24852. this.result.push(this.commandFactory.createEndComponent());
  24853. }
  24854. else {
  24855. this.result.push(this.commandFactory.createBeginElement(ast.name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, ast.isBound(), ast.ngContentIndex));
  24856. template_ast_1.templateVisitAll(this, ast.children);
  24857. this.result.push(this.commandFactory.createEndElement());
  24858. }
  24859. return null;
  24860. };
  24861. CommandBuilderVisitor.prototype.visitVariable = function (ast, ctx) { return null; };
  24862. CommandBuilderVisitor.prototype.visitAttr = function (ast, attrNameAndValues) {
  24863. attrNameAndValues.push(ast.name);
  24864. attrNameAndValues.push(ast.value);
  24865. return null;
  24866. };
  24867. CommandBuilderVisitor.prototype.visitBoundText = function (ast, context) {
  24868. this.result.push(this.commandFactory.createText(null, true, ast.ngContentIndex));
  24869. return null;
  24870. };
  24871. CommandBuilderVisitor.prototype.visitText = function (ast, context) {
  24872. this.result.push(this.commandFactory.createText(ast.value, false, ast.ngContentIndex));
  24873. return null;
  24874. };
  24875. CommandBuilderVisitor.prototype.visitDirective = function (ast, ctx) {
  24876. ctx.targetDirectives.push(ast.directive);
  24877. template_ast_1.templateVisitAll(this, ast.hostEvents, ctx.eventTargetAndNames);
  24878. ast.exportAsVars.forEach(function (varAst) {
  24879. ctx.targetVariableNameAndValues.push(varAst.name);
  24880. ctx.targetVariableNameAndValues.push(ctx.index);
  24881. });
  24882. return null;
  24883. };
  24884. CommandBuilderVisitor.prototype.visitEvent = function (ast, eventTargetAndNames) {
  24885. eventTargetAndNames.push(ast.target);
  24886. eventTargetAndNames.push(ast.name);
  24887. return null;
  24888. };
  24889. CommandBuilderVisitor.prototype.visitDirectiveProperty = function (ast, context) { return null; };
  24890. CommandBuilderVisitor.prototype.visitElementProperty = function (ast, context) { return null; };
  24891. return CommandBuilderVisitor;
  24892. })();
  24893. function removeKeyValueArrayDuplicates(keyValueArray) {
  24894. var knownPairs = new Set();
  24895. var resultKeyValueArray = [];
  24896. for (var i = 0; i < keyValueArray.length; i += 2) {
  24897. var key = keyValueArray[i];
  24898. var value = keyValueArray[i + 1];
  24899. var pairId = key + ":" + value;
  24900. if (!collection_1.SetWrapper.has(knownPairs, pairId)) {
  24901. resultKeyValueArray.push(key);
  24902. resultKeyValueArray.push(value);
  24903. knownPairs.add(pairId);
  24904. }
  24905. }
  24906. return resultKeyValueArray;
  24907. }
  24908. function keyValueArrayToMap(keyValueArr) {
  24909. var data = {};
  24910. for (var i = 0; i < keyValueArr.length; i += 2) {
  24911. data[keyValueArr[i]] = keyValueArr[i + 1];
  24912. }
  24913. return data;
  24914. }
  24915. function mapToKeyValueArray(data) {
  24916. var entryArray = [];
  24917. collection_1.StringMapWrapper.forEach(data, function (value, name) { entryArray.push([name, value]); });
  24918. // We need to sort to get a defined output order
  24919. // for tests and for caching generated artifacts...
  24920. collection_1.ListWrapper.sort(entryArray, function (entry1, entry2) { return lang_1.StringWrapper.compare(entry1[0], entry2[0]); });
  24921. var keyValueArray = [];
  24922. entryArray.forEach(function (entry) {
  24923. keyValueArray.push(entry[0]);
  24924. keyValueArray.push(entry[1]);
  24925. });
  24926. return keyValueArray;
  24927. }
  24928. function mergeAttributeValue(attrName, attrValue1, attrValue2) {
  24929. if (attrName == CLASS_ATTR || attrName == STYLE_ATTR) {
  24930. return attrValue1 + " " + attrValue2;
  24931. }
  24932. else {
  24933. return attrValue2;
  24934. }
  24935. }
  24936. var DirectiveContext = (function () {
  24937. function DirectiveContext(index, eventTargetAndNames, targetVariableNameAndValues, targetDirectives) {
  24938. this.index = index;
  24939. this.eventTargetAndNames = eventTargetAndNames;
  24940. this.targetVariableNameAndValues = targetVariableNameAndValues;
  24941. this.targetDirectives = targetDirectives;
  24942. }
  24943. return DirectiveContext;
  24944. })();
  24945. var Expression = (function () {
  24946. function Expression(value) {
  24947. this.value = value;
  24948. }
  24949. return Expression;
  24950. })();
  24951. function escapeValue(value) {
  24952. if (value instanceof Expression) {
  24953. return value.value;
  24954. }
  24955. else if (lang_1.isString(value)) {
  24956. return util_1.escapeSingleQuoteString(value);
  24957. }
  24958. else if (lang_1.isBlank(value)) {
  24959. return 'null';
  24960. }
  24961. else {
  24962. return "" + value;
  24963. }
  24964. }
  24965. function codeGenArray(data) {
  24966. var base = "[" + data.map(escapeValue).join(',') + "]";
  24967. return lang_1.IS_DART ? "const " + base : base;
  24968. }
  24969. function codeGenDirectivesArray(directives) {
  24970. var expressions = directives.map(function (directiveType) { return ("" + source_module_1.moduleRef(directiveType.type.moduleUrl) + directiveType.type.name); });
  24971. var base = "[" + expressions.join(',') + "]";
  24972. return lang_1.IS_DART ? "const " + base : base;
  24973. }
  24974. function codeGenViewEncapsulation(value) {
  24975. if (lang_1.IS_DART) {
  24976. return "" + exports.TEMPLATE_COMMANDS_MODULE_REF + value;
  24977. }
  24978. else {
  24979. return "" + value;
  24980. }
  24981. }
  24982. /***/ },
  24983. /* 167 */
  24984. /***/ function(module, exports, __webpack_require__) {
  24985. var __extends = (this && this.__extends) || function (d, b) {
  24986. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  24987. function __() { this.constructor = d; }
  24988. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24989. };
  24990. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  24991. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  24992. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  24993. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  24994. return c > 3 && r && Object.defineProperty(target, key, r), r;
  24995. };
  24996. var __metadata = (this && this.__metadata) || function (k, v) {
  24997. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  24998. };
  24999. var __param = (this && this.__param) || function (paramIndex, decorator) {
  25000. return function (target, key) { decorator(target, key, paramIndex); }
  25001. };
  25002. var collection_1 = __webpack_require__(12);
  25003. var lang_1 = __webpack_require__(5);
  25004. var core_1 = __webpack_require__(2);
  25005. var lang_2 = __webpack_require__(5);
  25006. var exceptions_1 = __webpack_require__(14);
  25007. var change_detection_1 = __webpack_require__(25);
  25008. var html_parser_1 = __webpack_require__(168);
  25009. var html_tags_1 = __webpack_require__(172);
  25010. var parse_util_1 = __webpack_require__(171);
  25011. var template_ast_1 = __webpack_require__(159);
  25012. var selector_1 = __webpack_require__(154);
  25013. var element_schema_registry_1 = __webpack_require__(173);
  25014. var template_preparser_1 = __webpack_require__(174);
  25015. var style_url_resolver_1 = __webpack_require__(163);
  25016. var html_ast_1 = __webpack_require__(169);
  25017. var util_1 = __webpack_require__(155);
  25018. // Group 1 = "bind-"
  25019. // Group 2 = "var-" or "#"
  25020. // Group 3 = "on-"
  25021. // Group 4 = "bindon-"
  25022. // Group 5 = the identifier after "bind-", "var-/#", or "on-"
  25023. // Group 6 = idenitifer inside [()]
  25024. // Group 7 = idenitifer inside []
  25025. // Group 8 = identifier inside ()
  25026. var BIND_NAME_REGEXP = /^(?:(?:(?:(bind-)|(var-|#)|(on-)|(bindon-))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/g;
  25027. var TEMPLATE_ELEMENT = 'template';
  25028. var TEMPLATE_ATTR = 'template';
  25029. var TEMPLATE_ATTR_PREFIX = '*';
  25030. var CLASS_ATTR = 'class';
  25031. var PROPERTY_PARTS_SEPARATOR = '.';
  25032. var ATTRIBUTE_PREFIX = 'attr';
  25033. var CLASS_PREFIX = 'class';
  25034. var STYLE_PREFIX = 'style';
  25035. var TEXT_CSS_SELECTOR = selector_1.CssSelector.parse('*')[0];
  25036. /**
  25037. * Provides an array of {@link TemplateAstVisitor}s which will be used to transform
  25038. * parsed templates before compilation is invoked, allowing custom expression syntax
  25039. * and other advanced transformations.
  25040. *
  25041. * This is currently an internal-only feature and not meant for general use.
  25042. */
  25043. exports.TEMPLATE_TRANSFORMS = lang_2.CONST_EXPR(new core_1.OpaqueToken('TemplateTransforms'));
  25044. var TemplateParseError = (function (_super) {
  25045. __extends(TemplateParseError, _super);
  25046. function TemplateParseError(message, location) {
  25047. _super.call(this, location, message);
  25048. }
  25049. return TemplateParseError;
  25050. })(parse_util_1.ParseError);
  25051. exports.TemplateParseError = TemplateParseError;
  25052. var TemplateParser = (function () {
  25053. function TemplateParser(_exprParser, _schemaRegistry, _htmlParser, transforms) {
  25054. this._exprParser = _exprParser;
  25055. this._schemaRegistry = _schemaRegistry;
  25056. this._htmlParser = _htmlParser;
  25057. this.transforms = transforms;
  25058. }
  25059. TemplateParser.prototype.parse = function (template, directives, templateUrl) {
  25060. var parseVisitor = new TemplateParseVisitor(directives, this._exprParser, this._schemaRegistry);
  25061. var htmlAstWithErrors = this._htmlParser.parse(template, templateUrl);
  25062. var result = html_ast_1.htmlVisitAll(parseVisitor, htmlAstWithErrors.rootNodes, EMPTY_COMPONENT);
  25063. var errors = htmlAstWithErrors.errors.concat(parseVisitor.errors);
  25064. if (errors.length > 0) {
  25065. var errorString = errors.join('\n');
  25066. throw new exceptions_1.BaseException("Template parse errors:\n" + errorString);
  25067. }
  25068. if (lang_1.isPresent(this.transforms)) {
  25069. this.transforms.forEach(function (transform) { result = template_ast_1.templateVisitAll(transform, result); });
  25070. }
  25071. return result;
  25072. };
  25073. TemplateParser = __decorate([
  25074. core_1.Injectable(),
  25075. __param(3, core_1.Optional()),
  25076. __param(3, core_1.Inject(exports.TEMPLATE_TRANSFORMS)),
  25077. __metadata('design:paramtypes', [change_detection_1.Parser, element_schema_registry_1.ElementSchemaRegistry, html_parser_1.HtmlParser, Array])
  25078. ], TemplateParser);
  25079. return TemplateParser;
  25080. })();
  25081. exports.TemplateParser = TemplateParser;
  25082. var TemplateParseVisitor = (function () {
  25083. function TemplateParseVisitor(directives, _exprParser, _schemaRegistry) {
  25084. var _this = this;
  25085. this._exprParser = _exprParser;
  25086. this._schemaRegistry = _schemaRegistry;
  25087. this.errors = [];
  25088. this.directivesIndex = new Map();
  25089. this.ngContentCount = 0;
  25090. this.selectorMatcher = new selector_1.SelectorMatcher();
  25091. collection_1.ListWrapper.forEachWithIndex(directives, function (directive, index) {
  25092. var selector = selector_1.CssSelector.parse(directive.selector);
  25093. _this.selectorMatcher.addSelectables(selector, directive);
  25094. _this.directivesIndex.set(directive, index);
  25095. });
  25096. }
  25097. TemplateParseVisitor.prototype._reportError = function (message, sourceSpan) {
  25098. this.errors.push(new TemplateParseError(message, sourceSpan.start));
  25099. };
  25100. TemplateParseVisitor.prototype._parseInterpolation = function (value, sourceSpan) {
  25101. var sourceInfo = sourceSpan.start.toString();
  25102. try {
  25103. return this._exprParser.parseInterpolation(value, sourceInfo);
  25104. }
  25105. catch (e) {
  25106. this._reportError("" + e, sourceSpan);
  25107. return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
  25108. }
  25109. };
  25110. TemplateParseVisitor.prototype._parseAction = function (value, sourceSpan) {
  25111. var sourceInfo = sourceSpan.start.toString();
  25112. try {
  25113. return this._exprParser.parseAction(value, sourceInfo);
  25114. }
  25115. catch (e) {
  25116. this._reportError("" + e, sourceSpan);
  25117. return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
  25118. }
  25119. };
  25120. TemplateParseVisitor.prototype._parseBinding = function (value, sourceSpan) {
  25121. var sourceInfo = sourceSpan.start.toString();
  25122. try {
  25123. return this._exprParser.parseBinding(value, sourceInfo);
  25124. }
  25125. catch (e) {
  25126. this._reportError("" + e, sourceSpan);
  25127. return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
  25128. }
  25129. };
  25130. TemplateParseVisitor.prototype._parseTemplateBindings = function (value, sourceSpan) {
  25131. var sourceInfo = sourceSpan.start.toString();
  25132. try {
  25133. return this._exprParser.parseTemplateBindings(value, sourceInfo);
  25134. }
  25135. catch (e) {
  25136. this._reportError("" + e, sourceSpan);
  25137. return [];
  25138. }
  25139. };
  25140. TemplateParseVisitor.prototype.visitText = function (ast, component) {
  25141. var ngContentIndex = component.findNgContentIndex(TEXT_CSS_SELECTOR);
  25142. var expr = this._parseInterpolation(ast.value, ast.sourceSpan);
  25143. if (lang_1.isPresent(expr)) {
  25144. return new template_ast_1.BoundTextAst(expr, ngContentIndex, ast.sourceSpan);
  25145. }
  25146. else {
  25147. return new template_ast_1.TextAst(ast.value, ngContentIndex, ast.sourceSpan);
  25148. }
  25149. };
  25150. TemplateParseVisitor.prototype.visitAttr = function (ast, contex) {
  25151. return new template_ast_1.AttrAst(ast.name, ast.value, ast.sourceSpan);
  25152. };
  25153. TemplateParseVisitor.prototype.visitElement = function (element, component) {
  25154. var _this = this;
  25155. var nodeName = element.name;
  25156. var preparsedElement = template_preparser_1.preparseElement(element);
  25157. if (preparsedElement.type === template_preparser_1.PreparsedElementType.SCRIPT ||
  25158. preparsedElement.type === template_preparser_1.PreparsedElementType.STYLE) {
  25159. // Skipping <script> for security reasons
  25160. // Skipping <style> as we already processed them
  25161. // in the StyleCompiler
  25162. return null;
  25163. }
  25164. if (preparsedElement.type === template_preparser_1.PreparsedElementType.STYLESHEET &&
  25165. style_url_resolver_1.isStyleUrlResolvable(preparsedElement.hrefAttr)) {
  25166. // Skipping stylesheets with either relative urls or package scheme as we already processed
  25167. // them in the StyleCompiler
  25168. return null;
  25169. }
  25170. var matchableAttrs = [];
  25171. var elementOrDirectiveProps = [];
  25172. var vars = [];
  25173. var events = [];
  25174. var templateElementOrDirectiveProps = [];
  25175. var templateVars = [];
  25176. var templateMatchableAttrs = [];
  25177. var hasInlineTemplates = false;
  25178. var attrs = [];
  25179. element.attrs.forEach(function (attr) {
  25180. matchableAttrs.push([attr.name, attr.value]);
  25181. var hasBinding = _this._parseAttr(attr, matchableAttrs, elementOrDirectiveProps, events, vars);
  25182. var hasTemplateBinding = _this._parseInlineTemplateBinding(attr, templateMatchableAttrs, templateElementOrDirectiveProps, templateVars);
  25183. if (!hasBinding && !hasTemplateBinding) {
  25184. // don't include the bindings as attributes as well in the AST
  25185. attrs.push(_this.visitAttr(attr, null));
  25186. }
  25187. if (hasTemplateBinding) {
  25188. hasInlineTemplates = true;
  25189. }
  25190. });
  25191. var lcElName = html_tags_1.splitNsName(nodeName.toLowerCase())[1];
  25192. var isTemplateElement = lcElName == TEMPLATE_ELEMENT;
  25193. var elementCssSelector = createElementCssSelector(nodeName, matchableAttrs);
  25194. var directives = this._createDirectiveAsts(element.name, this._parseDirectives(this.selectorMatcher, elementCssSelector), elementOrDirectiveProps, isTemplateElement ? [] : vars, element.sourceSpan);
  25195. var elementProps = this._createElementPropertyAsts(element.name, elementOrDirectiveProps, directives);
  25196. var children = html_ast_1.htmlVisitAll(preparsedElement.nonBindable ? NON_BINDABLE_VISITOR : this, element.children, Component.create(directives));
  25197. var elementNgContentIndex = hasInlineTemplates ? null : component.findNgContentIndex(elementCssSelector);
  25198. var parsedElement;
  25199. if (preparsedElement.type === template_preparser_1.PreparsedElementType.NG_CONTENT) {
  25200. if (lang_1.isPresent(element.children) && element.children.length > 0) {
  25201. this._reportError("<ng-content> element cannot have content. <ng-content> must be immediately followed by </ng-content>", element.sourceSpan);
  25202. }
  25203. parsedElement =
  25204. new template_ast_1.NgContentAst(this.ngContentCount++, elementNgContentIndex, element.sourceSpan);
  25205. }
  25206. else if (isTemplateElement) {
  25207. this._assertAllEventsPublishedByDirectives(directives, events);
  25208. this._assertNoComponentsNorElementBindingsOnTemplate(directives, elementProps, element.sourceSpan);
  25209. parsedElement = new template_ast_1.EmbeddedTemplateAst(attrs, events, vars, directives, children, elementNgContentIndex, element.sourceSpan);
  25210. }
  25211. else {
  25212. this._assertOnlyOneComponent(directives, element.sourceSpan);
  25213. var elementExportAsVars = vars.filter(function (varAst) { return varAst.value.length === 0; });
  25214. parsedElement =
  25215. new template_ast_1.ElementAst(nodeName, attrs, elementProps, events, elementExportAsVars, directives, children, elementNgContentIndex, element.sourceSpan);
  25216. }
  25217. if (hasInlineTemplates) {
  25218. var templateCssSelector = createElementCssSelector(TEMPLATE_ELEMENT, templateMatchableAttrs);
  25219. var templateDirectives = this._createDirectiveAsts(element.name, this._parseDirectives(this.selectorMatcher, templateCssSelector), templateElementOrDirectiveProps, [], element.sourceSpan);
  25220. var templateElementProps = this._createElementPropertyAsts(element.name, templateElementOrDirectiveProps, templateDirectives);
  25221. this._assertNoComponentsNorElementBindingsOnTemplate(templateDirectives, templateElementProps, element.sourceSpan);
  25222. parsedElement = new template_ast_1.EmbeddedTemplateAst([], [], templateVars, templateDirectives, [parsedElement], component.findNgContentIndex(templateCssSelector), element.sourceSpan);
  25223. }
  25224. return parsedElement;
  25225. };
  25226. TemplateParseVisitor.prototype._parseInlineTemplateBinding = function (attr, targetMatchableAttrs, targetProps, targetVars) {
  25227. var templateBindingsSource = null;
  25228. if (attr.name == TEMPLATE_ATTR) {
  25229. templateBindingsSource = attr.value;
  25230. }
  25231. else if (attr.name.startsWith(TEMPLATE_ATTR_PREFIX)) {
  25232. var key = attr.name.substring(TEMPLATE_ATTR_PREFIX.length); // remove the star
  25233. templateBindingsSource = (attr.value.length == 0) ? key : key + ' ' + attr.value;
  25234. }
  25235. if (lang_1.isPresent(templateBindingsSource)) {
  25236. var bindings = this._parseTemplateBindings(templateBindingsSource, attr.sourceSpan);
  25237. for (var i = 0; i < bindings.length; i++) {
  25238. var binding = bindings[i];
  25239. if (binding.keyIsVar) {
  25240. targetVars.push(new template_ast_1.VariableAst(binding.key, binding.name, attr.sourceSpan));
  25241. targetMatchableAttrs.push([binding.key, binding.name]);
  25242. }
  25243. else if (lang_1.isPresent(binding.expression)) {
  25244. this._parsePropertyAst(binding.key, binding.expression, attr.sourceSpan, targetMatchableAttrs, targetProps);
  25245. }
  25246. else {
  25247. targetMatchableAttrs.push([binding.key, '']);
  25248. this._parseLiteralAttr(binding.key, null, attr.sourceSpan, targetProps);
  25249. }
  25250. }
  25251. return true;
  25252. }
  25253. return false;
  25254. };
  25255. TemplateParseVisitor.prototype._parseAttr = function (attr, targetMatchableAttrs, targetProps, targetEvents, targetVars) {
  25256. var attrName = this._normalizeAttributeName(attr.name);
  25257. var attrValue = attr.value;
  25258. var bindParts = lang_1.RegExpWrapper.firstMatch(BIND_NAME_REGEXP, attrName);
  25259. var hasBinding = false;
  25260. if (lang_1.isPresent(bindParts)) {
  25261. hasBinding = true;
  25262. if (lang_1.isPresent(bindParts[1])) {
  25263. this._parseProperty(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
  25264. }
  25265. else if (lang_1.isPresent(bindParts[2])) {
  25266. var identifier = bindParts[5];
  25267. this._parseVariable(identifier, attrValue, attr.sourceSpan, targetVars);
  25268. }
  25269. else if (lang_1.isPresent(bindParts[3])) {
  25270. this._parseEvent(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
  25271. }
  25272. else if (lang_1.isPresent(bindParts[4])) {
  25273. this._parseProperty(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
  25274. this._parseAssignmentEvent(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
  25275. }
  25276. else if (lang_1.isPresent(bindParts[6])) {
  25277. this._parseProperty(bindParts[6], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
  25278. this._parseAssignmentEvent(bindParts[6], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
  25279. }
  25280. else if (lang_1.isPresent(bindParts[7])) {
  25281. this._parseProperty(bindParts[7], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
  25282. }
  25283. else if (lang_1.isPresent(bindParts[8])) {
  25284. this._parseEvent(bindParts[8], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
  25285. }
  25286. }
  25287. else {
  25288. hasBinding = this._parsePropertyInterpolation(attrName, attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
  25289. }
  25290. if (!hasBinding) {
  25291. this._parseLiteralAttr(attrName, attrValue, attr.sourceSpan, targetProps);
  25292. }
  25293. return hasBinding;
  25294. };
  25295. TemplateParseVisitor.prototype._normalizeAttributeName = function (attrName) {
  25296. return attrName.toLowerCase().startsWith('data-') ? attrName.substring(5) : attrName;
  25297. };
  25298. TemplateParseVisitor.prototype._parseVariable = function (identifier, value, sourceSpan, targetVars) {
  25299. if (identifier.indexOf('-') > -1) {
  25300. this._reportError("\"-\" is not allowed in variable names", sourceSpan);
  25301. }
  25302. targetVars.push(new template_ast_1.VariableAst(identifier, value, sourceSpan));
  25303. };
  25304. TemplateParseVisitor.prototype._parseProperty = function (name, expression, sourceSpan, targetMatchableAttrs, targetProps) {
  25305. this._parsePropertyAst(name, this._parseBinding(expression, sourceSpan), sourceSpan, targetMatchableAttrs, targetProps);
  25306. };
  25307. TemplateParseVisitor.prototype._parsePropertyInterpolation = function (name, value, sourceSpan, targetMatchableAttrs, targetProps) {
  25308. var expr = this._parseInterpolation(value, sourceSpan);
  25309. if (lang_1.isPresent(expr)) {
  25310. this._parsePropertyAst(name, expr, sourceSpan, targetMatchableAttrs, targetProps);
  25311. return true;
  25312. }
  25313. return false;
  25314. };
  25315. TemplateParseVisitor.prototype._parsePropertyAst = function (name, ast, sourceSpan, targetMatchableAttrs, targetProps) {
  25316. targetMatchableAttrs.push([name, ast.source]);
  25317. targetProps.push(new BoundElementOrDirectiveProperty(name, ast, false, sourceSpan));
  25318. };
  25319. TemplateParseVisitor.prototype._parseAssignmentEvent = function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
  25320. this._parseEvent(name + "Change", expression + "=$event", sourceSpan, targetMatchableAttrs, targetEvents);
  25321. };
  25322. TemplateParseVisitor.prototype._parseEvent = function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
  25323. // long format: 'target: eventName'
  25324. var parts = util_1.splitAtColon(name, [null, name]);
  25325. var target = parts[0];
  25326. var eventName = parts[1];
  25327. targetEvents.push(new template_ast_1.BoundEventAst(eventName, target, this._parseAction(expression, sourceSpan), sourceSpan));
  25328. // Don't detect directives for event names for now,
  25329. // so don't add the event name to the matchableAttrs
  25330. };
  25331. TemplateParseVisitor.prototype._parseLiteralAttr = function (name, value, sourceSpan, targetProps) {
  25332. targetProps.push(new BoundElementOrDirectiveProperty(name, this._exprParser.wrapLiteralPrimitive(value, ''), true, sourceSpan));
  25333. };
  25334. TemplateParseVisitor.prototype._parseDirectives = function (selectorMatcher, elementCssSelector) {
  25335. var _this = this;
  25336. var directives = [];
  25337. selectorMatcher.match(elementCssSelector, function (selector, directive) { directives.push(directive); });
  25338. // Need to sort the directives so that we get consistent results throughout,
  25339. // as selectorMatcher uses Maps inside.
  25340. // Also need to make components the first directive in the array
  25341. collection_1.ListWrapper.sort(directives, function (dir1, dir2) {
  25342. var dir1Comp = dir1.isComponent;
  25343. var dir2Comp = dir2.isComponent;
  25344. if (dir1Comp && !dir2Comp) {
  25345. return -1;
  25346. }
  25347. else if (!dir1Comp && dir2Comp) {
  25348. return 1;
  25349. }
  25350. else {
  25351. return _this.directivesIndex.get(dir1) - _this.directivesIndex.get(dir2);
  25352. }
  25353. });
  25354. return directives;
  25355. };
  25356. TemplateParseVisitor.prototype._createDirectiveAsts = function (elementName, directives, props, possibleExportAsVars, sourceSpan) {
  25357. var _this = this;
  25358. var matchedVariables = new Set();
  25359. var directiveAsts = directives.map(function (directive) {
  25360. var hostProperties = [];
  25361. var hostEvents = [];
  25362. var directiveProperties = [];
  25363. _this._createDirectiveHostPropertyAsts(elementName, directive.hostProperties, sourceSpan, hostProperties);
  25364. _this._createDirectiveHostEventAsts(directive.hostListeners, sourceSpan, hostEvents);
  25365. _this._createDirectivePropertyAsts(directive.inputs, props, directiveProperties);
  25366. var exportAsVars = [];
  25367. possibleExportAsVars.forEach(function (varAst) {
  25368. if ((varAst.value.length === 0 && directive.isComponent) ||
  25369. (directive.exportAs == varAst.value)) {
  25370. exportAsVars.push(varAst);
  25371. matchedVariables.add(varAst.name);
  25372. }
  25373. });
  25374. return new template_ast_1.DirectiveAst(directive, directiveProperties, hostProperties, hostEvents, exportAsVars, sourceSpan);
  25375. });
  25376. possibleExportAsVars.forEach(function (varAst) {
  25377. if (varAst.value.length > 0 && !collection_1.SetWrapper.has(matchedVariables, varAst.name)) {
  25378. _this._reportError("There is no directive with \"exportAs\" set to \"" + varAst.value + "\"", varAst.sourceSpan);
  25379. }
  25380. });
  25381. return directiveAsts;
  25382. };
  25383. TemplateParseVisitor.prototype._createDirectiveHostPropertyAsts = function (elementName, hostProps, sourceSpan, targetPropertyAsts) {
  25384. var _this = this;
  25385. if (lang_1.isPresent(hostProps)) {
  25386. collection_1.StringMapWrapper.forEach(hostProps, function (expression, propName) {
  25387. var exprAst = _this._parseBinding(expression, sourceSpan);
  25388. targetPropertyAsts.push(_this._createElementPropertyAst(elementName, propName, exprAst, sourceSpan));
  25389. });
  25390. }
  25391. };
  25392. TemplateParseVisitor.prototype._createDirectiveHostEventAsts = function (hostListeners, sourceSpan, targetEventAsts) {
  25393. var _this = this;
  25394. if (lang_1.isPresent(hostListeners)) {
  25395. collection_1.StringMapWrapper.forEach(hostListeners, function (expression, propName) {
  25396. _this._parseEvent(propName, expression, sourceSpan, [], targetEventAsts);
  25397. });
  25398. }
  25399. };
  25400. TemplateParseVisitor.prototype._createDirectivePropertyAsts = function (directiveProperties, boundProps, targetBoundDirectiveProps) {
  25401. if (lang_1.isPresent(directiveProperties)) {
  25402. var boundPropsByName = new Map();
  25403. boundProps.forEach(function (boundProp) {
  25404. var prevValue = boundPropsByName.get(boundProp.name);
  25405. if (lang_1.isBlank(prevValue) || prevValue.isLiteral) {
  25406. // give [a]="b" a higher precedence than a="b" on the same element
  25407. boundPropsByName.set(boundProp.name, boundProp);
  25408. }
  25409. });
  25410. collection_1.StringMapWrapper.forEach(directiveProperties, function (elProp, dirProp) {
  25411. var boundProp = boundPropsByName.get(elProp);
  25412. // Bindings are optional, so this binding only needs to be set up if an expression is given.
  25413. if (lang_1.isPresent(boundProp)) {
  25414. targetBoundDirectiveProps.push(new template_ast_1.BoundDirectivePropertyAst(dirProp, boundProp.name, boundProp.expression, boundProp.sourceSpan));
  25415. }
  25416. });
  25417. }
  25418. };
  25419. TemplateParseVisitor.prototype._createElementPropertyAsts = function (elementName, props, directives) {
  25420. var _this = this;
  25421. var boundElementProps = [];
  25422. var boundDirectivePropsIndex = new Map();
  25423. directives.forEach(function (directive) {
  25424. directive.inputs.forEach(function (prop) {
  25425. boundDirectivePropsIndex.set(prop.templateName, prop);
  25426. });
  25427. });
  25428. props.forEach(function (prop) {
  25429. if (!prop.isLiteral && lang_1.isBlank(boundDirectivePropsIndex.get(prop.name))) {
  25430. boundElementProps.push(_this._createElementPropertyAst(elementName, prop.name, prop.expression, prop.sourceSpan));
  25431. }
  25432. });
  25433. return boundElementProps;
  25434. };
  25435. TemplateParseVisitor.prototype._createElementPropertyAst = function (elementName, name, ast, sourceSpan) {
  25436. var unit = null;
  25437. var bindingType;
  25438. var boundPropertyName;
  25439. var parts = name.split(PROPERTY_PARTS_SEPARATOR);
  25440. if (parts.length === 1) {
  25441. boundPropertyName = this._schemaRegistry.getMappedPropName(parts[0]);
  25442. bindingType = template_ast_1.PropertyBindingType.Property;
  25443. if (!this._schemaRegistry.hasProperty(elementName, boundPropertyName)) {
  25444. this._reportError("Can't bind to '" + boundPropertyName + "' since it isn't a known native property", sourceSpan);
  25445. }
  25446. }
  25447. else {
  25448. if (parts[0] == ATTRIBUTE_PREFIX) {
  25449. boundPropertyName = parts[1];
  25450. bindingType = template_ast_1.PropertyBindingType.Attribute;
  25451. }
  25452. else if (parts[0] == CLASS_PREFIX) {
  25453. boundPropertyName = parts[1];
  25454. bindingType = template_ast_1.PropertyBindingType.Class;
  25455. }
  25456. else if (parts[0] == STYLE_PREFIX) {
  25457. unit = parts.length > 2 ? parts[2] : null;
  25458. boundPropertyName = parts[1];
  25459. bindingType = template_ast_1.PropertyBindingType.Style;
  25460. }
  25461. else {
  25462. this._reportError("Invalid property name '" + name + "'", sourceSpan);
  25463. bindingType = null;
  25464. }
  25465. }
  25466. return new template_ast_1.BoundElementPropertyAst(boundPropertyName, bindingType, ast, unit, sourceSpan);
  25467. };
  25468. TemplateParseVisitor.prototype._findComponentDirectiveNames = function (directives) {
  25469. var componentTypeNames = [];
  25470. directives.forEach(function (directive) {
  25471. var typeName = directive.directive.type.name;
  25472. if (directive.directive.isComponent) {
  25473. componentTypeNames.push(typeName);
  25474. }
  25475. });
  25476. return componentTypeNames;
  25477. };
  25478. TemplateParseVisitor.prototype._assertOnlyOneComponent = function (directives, sourceSpan) {
  25479. var componentTypeNames = this._findComponentDirectiveNames(directives);
  25480. if (componentTypeNames.length > 1) {
  25481. this._reportError("More than one component: " + componentTypeNames.join(','), sourceSpan);
  25482. }
  25483. };
  25484. TemplateParseVisitor.prototype._assertNoComponentsNorElementBindingsOnTemplate = function (directives, elementProps, sourceSpan) {
  25485. var _this = this;
  25486. var componentTypeNames = this._findComponentDirectiveNames(directives);
  25487. if (componentTypeNames.length > 0) {
  25488. this._reportError("Components on an embedded template: " + componentTypeNames.join(','), sourceSpan);
  25489. }
  25490. elementProps.forEach(function (prop) {
  25491. _this._reportError("Property binding " + prop.name + " not used by any directive on an embedded template", sourceSpan);
  25492. });
  25493. };
  25494. TemplateParseVisitor.prototype._assertAllEventsPublishedByDirectives = function (directives, events) {
  25495. var _this = this;
  25496. var allDirectiveEvents = new Set();
  25497. directives.forEach(function (directive) {
  25498. collection_1.StringMapWrapper.forEach(directive.directive.outputs, function (eventName, _) { allDirectiveEvents.add(eventName); });
  25499. });
  25500. events.forEach(function (event) {
  25501. if (lang_1.isPresent(event.target) || !collection_1.SetWrapper.has(allDirectiveEvents, event.name)) {
  25502. _this._reportError("Event binding " + event.fullName + " not emitted by any directive on an embedded template", event.sourceSpan);
  25503. }
  25504. });
  25505. };
  25506. return TemplateParseVisitor;
  25507. })();
  25508. var NonBindableVisitor = (function () {
  25509. function NonBindableVisitor() {
  25510. }
  25511. NonBindableVisitor.prototype.visitElement = function (ast, component) {
  25512. var preparsedElement = template_preparser_1.preparseElement(ast);
  25513. if (preparsedElement.type === template_preparser_1.PreparsedElementType.SCRIPT ||
  25514. preparsedElement.type === template_preparser_1.PreparsedElementType.STYLE ||
  25515. preparsedElement.type === template_preparser_1.PreparsedElementType.STYLESHEET) {
  25516. // Skipping <script> for security reasons
  25517. // Skipping <style> and stylesheets as we already processed them
  25518. // in the StyleCompiler
  25519. return null;
  25520. }
  25521. var attrNameAndValues = ast.attrs.map(function (attrAst) { return [attrAst.name, attrAst.value]; });
  25522. var selector = createElementCssSelector(ast.name, attrNameAndValues);
  25523. var ngContentIndex = component.findNgContentIndex(selector);
  25524. var children = html_ast_1.htmlVisitAll(this, ast.children, EMPTY_COMPONENT);
  25525. return new template_ast_1.ElementAst(ast.name, html_ast_1.htmlVisitAll(this, ast.attrs), [], [], [], [], children, ngContentIndex, ast.sourceSpan);
  25526. };
  25527. NonBindableVisitor.prototype.visitAttr = function (ast, context) {
  25528. return new template_ast_1.AttrAst(ast.name, ast.value, ast.sourceSpan);
  25529. };
  25530. NonBindableVisitor.prototype.visitText = function (ast, component) {
  25531. var ngContentIndex = component.findNgContentIndex(TEXT_CSS_SELECTOR);
  25532. return new template_ast_1.TextAst(ast.value, ngContentIndex, ast.sourceSpan);
  25533. };
  25534. return NonBindableVisitor;
  25535. })();
  25536. var BoundElementOrDirectiveProperty = (function () {
  25537. function BoundElementOrDirectiveProperty(name, expression, isLiteral, sourceSpan) {
  25538. this.name = name;
  25539. this.expression = expression;
  25540. this.isLiteral = isLiteral;
  25541. this.sourceSpan = sourceSpan;
  25542. }
  25543. return BoundElementOrDirectiveProperty;
  25544. })();
  25545. function splitClasses(classAttrValue) {
  25546. return lang_1.StringWrapper.split(classAttrValue.trim(), /\s+/g);
  25547. }
  25548. exports.splitClasses = splitClasses;
  25549. var Component = (function () {
  25550. function Component(ngContentIndexMatcher, wildcardNgContentIndex) {
  25551. this.ngContentIndexMatcher = ngContentIndexMatcher;
  25552. this.wildcardNgContentIndex = wildcardNgContentIndex;
  25553. }
  25554. Component.create = function (directives) {
  25555. if (directives.length === 0 || !directives[0].directive.isComponent) {
  25556. return EMPTY_COMPONENT;
  25557. }
  25558. var matcher = new selector_1.SelectorMatcher();
  25559. var ngContentSelectors = directives[0].directive.template.ngContentSelectors;
  25560. var wildcardNgContentIndex = null;
  25561. for (var i = 0; i < ngContentSelectors.length; i++) {
  25562. var selector = ngContentSelectors[i];
  25563. if (lang_1.StringWrapper.equals(selector, '*')) {
  25564. wildcardNgContentIndex = i;
  25565. }
  25566. else {
  25567. matcher.addSelectables(selector_1.CssSelector.parse(ngContentSelectors[i]), i);
  25568. }
  25569. }
  25570. return new Component(matcher, wildcardNgContentIndex);
  25571. };
  25572. Component.prototype.findNgContentIndex = function (selector) {
  25573. var ngContentIndices = [];
  25574. this.ngContentIndexMatcher.match(selector, function (selector, ngContentIndex) { ngContentIndices.push(ngContentIndex); });
  25575. collection_1.ListWrapper.sort(ngContentIndices);
  25576. if (lang_1.isPresent(this.wildcardNgContentIndex)) {
  25577. ngContentIndices.push(this.wildcardNgContentIndex);
  25578. }
  25579. return ngContentIndices.length > 0 ? ngContentIndices[0] : null;
  25580. };
  25581. return Component;
  25582. })();
  25583. function createElementCssSelector(elementName, matchableAttrs) {
  25584. var cssSelector = new selector_1.CssSelector();
  25585. var elNameNoNs = html_tags_1.splitNsName(elementName)[1];
  25586. cssSelector.setElement(elNameNoNs);
  25587. for (var i = 0; i < matchableAttrs.length; i++) {
  25588. var attrName = matchableAttrs[i][0];
  25589. var attrNameNoNs = html_tags_1.splitNsName(attrName)[1];
  25590. var attrValue = matchableAttrs[i][1];
  25591. cssSelector.addAttribute(attrNameNoNs, attrValue);
  25592. if (attrName.toLowerCase() == CLASS_ATTR) {
  25593. var classes = splitClasses(attrValue);
  25594. classes.forEach(function (className) { return cssSelector.addClassName(className); });
  25595. }
  25596. }
  25597. return cssSelector;
  25598. }
  25599. var EMPTY_COMPONENT = new Component(new selector_1.SelectorMatcher(), null);
  25600. var NON_BINDABLE_VISITOR = new NonBindableVisitor();
  25601. /***/ },
  25602. /* 168 */
  25603. /***/ function(module, exports, __webpack_require__) {
  25604. var __extends = (this && this.__extends) || function (d, b) {
  25605. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  25606. function __() { this.constructor = d; }
  25607. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  25608. };
  25609. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  25610. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  25611. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  25612. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  25613. return c > 3 && r && Object.defineProperty(target, key, r), r;
  25614. };
  25615. var __metadata = (this && this.__metadata) || function (k, v) {
  25616. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  25617. };
  25618. var lang_1 = __webpack_require__(5);
  25619. var collection_1 = __webpack_require__(12);
  25620. var html_ast_1 = __webpack_require__(169);
  25621. var di_1 = __webpack_require__(6);
  25622. var html_lexer_1 = __webpack_require__(170);
  25623. var parse_util_1 = __webpack_require__(171);
  25624. var html_tags_1 = __webpack_require__(172);
  25625. var HtmlTreeError = (function (_super) {
  25626. __extends(HtmlTreeError, _super);
  25627. function HtmlTreeError(elementName, location, msg) {
  25628. _super.call(this, location, msg);
  25629. this.elementName = elementName;
  25630. }
  25631. HtmlTreeError.create = function (elementName, location, msg) {
  25632. return new HtmlTreeError(elementName, location, msg);
  25633. };
  25634. return HtmlTreeError;
  25635. })(parse_util_1.ParseError);
  25636. exports.HtmlTreeError = HtmlTreeError;
  25637. var HtmlParseTreeResult = (function () {
  25638. function HtmlParseTreeResult(rootNodes, errors) {
  25639. this.rootNodes = rootNodes;
  25640. this.errors = errors;
  25641. }
  25642. return HtmlParseTreeResult;
  25643. })();
  25644. exports.HtmlParseTreeResult = HtmlParseTreeResult;
  25645. var HtmlParser = (function () {
  25646. function HtmlParser() {
  25647. }
  25648. HtmlParser.prototype.parse = function (sourceContent, sourceUrl) {
  25649. var tokensAndErrors = html_lexer_1.tokenizeHtml(sourceContent, sourceUrl);
  25650. var treeAndErrors = new TreeBuilder(tokensAndErrors.tokens).build();
  25651. return new HtmlParseTreeResult(treeAndErrors.rootNodes, tokensAndErrors.errors
  25652. .concat(treeAndErrors.errors));
  25653. };
  25654. HtmlParser = __decorate([
  25655. di_1.Injectable(),
  25656. __metadata('design:paramtypes', [])
  25657. ], HtmlParser);
  25658. return HtmlParser;
  25659. })();
  25660. exports.HtmlParser = HtmlParser;
  25661. var TreeBuilder = (function () {
  25662. function TreeBuilder(tokens) {
  25663. this.tokens = tokens;
  25664. this.index = -1;
  25665. this.rootNodes = [];
  25666. this.errors = [];
  25667. this.elementStack = [];
  25668. this._advance();
  25669. }
  25670. TreeBuilder.prototype.build = function () {
  25671. while (this.peek.type !== html_lexer_1.HtmlTokenType.EOF) {
  25672. if (this.peek.type === html_lexer_1.HtmlTokenType.TAG_OPEN_START) {
  25673. this._consumeStartTag(this._advance());
  25674. }
  25675. else if (this.peek.type === html_lexer_1.HtmlTokenType.TAG_CLOSE) {
  25676. this._consumeEndTag(this._advance());
  25677. }
  25678. else if (this.peek.type === html_lexer_1.HtmlTokenType.CDATA_START) {
  25679. this._closeVoidElement();
  25680. this._consumeCdata(this._advance());
  25681. }
  25682. else if (this.peek.type === html_lexer_1.HtmlTokenType.COMMENT_START) {
  25683. this._closeVoidElement();
  25684. this._consumeComment(this._advance());
  25685. }
  25686. else if (this.peek.type === html_lexer_1.HtmlTokenType.TEXT ||
  25687. this.peek.type === html_lexer_1.HtmlTokenType.RAW_TEXT ||
  25688. this.peek.type === html_lexer_1.HtmlTokenType.ESCAPABLE_RAW_TEXT) {
  25689. this._closeVoidElement();
  25690. this._consumeText(this._advance());
  25691. }
  25692. else {
  25693. // Skip all other tokens...
  25694. this._advance();
  25695. }
  25696. }
  25697. return new HtmlParseTreeResult(this.rootNodes, this.errors);
  25698. };
  25699. TreeBuilder.prototype._advance = function () {
  25700. var prev = this.peek;
  25701. if (this.index < this.tokens.length - 1) {
  25702. // Note: there is always an EOF token at the end
  25703. this.index++;
  25704. }
  25705. this.peek = this.tokens[this.index];
  25706. return prev;
  25707. };
  25708. TreeBuilder.prototype._advanceIf = function (type) {
  25709. if (this.peek.type === type) {
  25710. return this._advance();
  25711. }
  25712. return null;
  25713. };
  25714. TreeBuilder.prototype._consumeCdata = function (startToken) {
  25715. this._consumeText(this._advance());
  25716. this._advanceIf(html_lexer_1.HtmlTokenType.CDATA_END);
  25717. };
  25718. TreeBuilder.prototype._consumeComment = function (startToken) {
  25719. this._advanceIf(html_lexer_1.HtmlTokenType.RAW_TEXT);
  25720. this._advanceIf(html_lexer_1.HtmlTokenType.COMMENT_END);
  25721. };
  25722. TreeBuilder.prototype._consumeText = function (token) {
  25723. var text = token.parts[0];
  25724. if (text.length > 0 && text[0] == '\n') {
  25725. var parent_1 = this._getParentElement();
  25726. if (lang_1.isPresent(parent_1) && parent_1.children.length == 0 &&
  25727. html_tags_1.getHtmlTagDefinition(parent_1.name).ignoreFirstLf) {
  25728. text = text.substring(1);
  25729. }
  25730. }
  25731. if (text.length > 0) {
  25732. this._addToParent(new html_ast_1.HtmlTextAst(text, token.sourceSpan));
  25733. }
  25734. };
  25735. TreeBuilder.prototype._closeVoidElement = function () {
  25736. if (this.elementStack.length > 0) {
  25737. var el = collection_1.ListWrapper.last(this.elementStack);
  25738. if (html_tags_1.getHtmlTagDefinition(el.name).isVoid) {
  25739. this.elementStack.pop();
  25740. }
  25741. }
  25742. };
  25743. TreeBuilder.prototype._consumeStartTag = function (startTagToken) {
  25744. var prefix = startTagToken.parts[0];
  25745. var name = startTagToken.parts[1];
  25746. var attrs = [];
  25747. while (this.peek.type === html_lexer_1.HtmlTokenType.ATTR_NAME) {
  25748. attrs.push(this._consumeAttr(this._advance()));
  25749. }
  25750. var fullName = getElementFullName(prefix, name, this._getParentElement());
  25751. var selfClosing = false;
  25752. // Note: There could have been a tokenizer error
  25753. // so that we don't get a token for the end tag...
  25754. if (this.peek.type === html_lexer_1.HtmlTokenType.TAG_OPEN_END_VOID) {
  25755. this._advance();
  25756. selfClosing = true;
  25757. if (html_tags_1.getNsPrefix(fullName) == null && !html_tags_1.getHtmlTagDefinition(fullName).isVoid) {
  25758. this.errors.push(HtmlTreeError.create(fullName, startTagToken.sourceSpan.start, "Only void and foreign elements can be self closed \"" + startTagToken.parts[1] + "\""));
  25759. }
  25760. }
  25761. else if (this.peek.type === html_lexer_1.HtmlTokenType.TAG_OPEN_END) {
  25762. this._advance();
  25763. selfClosing = false;
  25764. }
  25765. var end = this.peek.sourceSpan.start;
  25766. var el = new html_ast_1.HtmlElementAst(fullName, attrs, [], new parse_util_1.ParseSourceSpan(startTagToken.sourceSpan.start, end));
  25767. this._pushElement(el);
  25768. if (selfClosing) {
  25769. this._popElement(fullName);
  25770. }
  25771. };
  25772. TreeBuilder.prototype._pushElement = function (el) {
  25773. if (this.elementStack.length > 0) {
  25774. var parentEl = collection_1.ListWrapper.last(this.elementStack);
  25775. if (html_tags_1.getHtmlTagDefinition(parentEl.name).isClosedByChild(el.name)) {
  25776. this.elementStack.pop();
  25777. }
  25778. }
  25779. var tagDef = html_tags_1.getHtmlTagDefinition(el.name);
  25780. var parentEl = this._getParentElement();
  25781. if (tagDef.requireExtraParent(lang_1.isPresent(parentEl) ? parentEl.name : null)) {
  25782. var newParent = new html_ast_1.HtmlElementAst(tagDef.parentToAdd, [], [el], el.sourceSpan);
  25783. this._addToParent(newParent);
  25784. this.elementStack.push(newParent);
  25785. this.elementStack.push(el);
  25786. }
  25787. else {
  25788. this._addToParent(el);
  25789. this.elementStack.push(el);
  25790. }
  25791. };
  25792. TreeBuilder.prototype._consumeEndTag = function (endTagToken) {
  25793. var fullName = getElementFullName(endTagToken.parts[0], endTagToken.parts[1], this._getParentElement());
  25794. if (html_tags_1.getHtmlTagDefinition(fullName).isVoid) {
  25795. this.errors.push(HtmlTreeError.create(fullName, endTagToken.sourceSpan.start, "Void elements do not have end tags \"" + endTagToken.parts[1] + "\""));
  25796. }
  25797. else if (!this._popElement(fullName)) {
  25798. this.errors.push(HtmlTreeError.create(fullName, endTagToken.sourceSpan.start, "Unexpected closing tag \"" + endTagToken.parts[1] + "\""));
  25799. }
  25800. };
  25801. TreeBuilder.prototype._popElement = function (fullName) {
  25802. for (var stackIndex = this.elementStack.length - 1; stackIndex >= 0; stackIndex--) {
  25803. var el = this.elementStack[stackIndex];
  25804. if (el.name == fullName) {
  25805. collection_1.ListWrapper.splice(this.elementStack, stackIndex, this.elementStack.length - stackIndex);
  25806. return true;
  25807. }
  25808. if (!html_tags_1.getHtmlTagDefinition(el.name).closedByParent) {
  25809. return false;
  25810. }
  25811. }
  25812. return false;
  25813. };
  25814. TreeBuilder.prototype._consumeAttr = function (attrName) {
  25815. var fullName = mergeNsAndName(attrName.parts[0], attrName.parts[1]);
  25816. var end = attrName.sourceSpan.end;
  25817. var value = '';
  25818. if (this.peek.type === html_lexer_1.HtmlTokenType.ATTR_VALUE) {
  25819. var valueToken = this._advance();
  25820. value = valueToken.parts[0];
  25821. end = valueToken.sourceSpan.end;
  25822. }
  25823. return new html_ast_1.HtmlAttrAst(fullName, value, new parse_util_1.ParseSourceSpan(attrName.sourceSpan.start, end));
  25824. };
  25825. TreeBuilder.prototype._getParentElement = function () {
  25826. return this.elementStack.length > 0 ? collection_1.ListWrapper.last(this.elementStack) : null;
  25827. };
  25828. TreeBuilder.prototype._addToParent = function (node) {
  25829. var parent = this._getParentElement();
  25830. if (lang_1.isPresent(parent)) {
  25831. parent.children.push(node);
  25832. }
  25833. else {
  25834. this.rootNodes.push(node);
  25835. }
  25836. };
  25837. return TreeBuilder;
  25838. })();
  25839. function mergeNsAndName(prefix, localName) {
  25840. return lang_1.isPresent(prefix) ? "@" + prefix + ":" + localName : localName;
  25841. }
  25842. function getElementFullName(prefix, localName, parentElement) {
  25843. if (lang_1.isBlank(prefix)) {
  25844. prefix = html_tags_1.getHtmlTagDefinition(localName).implicitNamespacePrefix;
  25845. if (lang_1.isBlank(prefix) && lang_1.isPresent(parentElement)) {
  25846. prefix = html_tags_1.getNsPrefix(parentElement.name);
  25847. }
  25848. }
  25849. return mergeNsAndName(prefix, localName);
  25850. }
  25851. /***/ },
  25852. /* 169 */
  25853. /***/ function(module, exports, __webpack_require__) {
  25854. var lang_1 = __webpack_require__(5);
  25855. var HtmlTextAst = (function () {
  25856. function HtmlTextAst(value, sourceSpan) {
  25857. this.value = value;
  25858. this.sourceSpan = sourceSpan;
  25859. }
  25860. HtmlTextAst.prototype.visit = function (visitor, context) { return visitor.visitText(this, context); };
  25861. return HtmlTextAst;
  25862. })();
  25863. exports.HtmlTextAst = HtmlTextAst;
  25864. var HtmlAttrAst = (function () {
  25865. function HtmlAttrAst(name, value, sourceSpan) {
  25866. this.name = name;
  25867. this.value = value;
  25868. this.sourceSpan = sourceSpan;
  25869. }
  25870. HtmlAttrAst.prototype.visit = function (visitor, context) { return visitor.visitAttr(this, context); };
  25871. return HtmlAttrAst;
  25872. })();
  25873. exports.HtmlAttrAst = HtmlAttrAst;
  25874. var HtmlElementAst = (function () {
  25875. function HtmlElementAst(name, attrs, children, sourceSpan) {
  25876. this.name = name;
  25877. this.attrs = attrs;
  25878. this.children = children;
  25879. this.sourceSpan = sourceSpan;
  25880. }
  25881. HtmlElementAst.prototype.visit = function (visitor, context) { return visitor.visitElement(this, context); };
  25882. return HtmlElementAst;
  25883. })();
  25884. exports.HtmlElementAst = HtmlElementAst;
  25885. function htmlVisitAll(visitor, asts, context) {
  25886. if (context === void 0) { context = null; }
  25887. var result = [];
  25888. asts.forEach(function (ast) {
  25889. var astResult = ast.visit(visitor, context);
  25890. if (lang_1.isPresent(astResult)) {
  25891. result.push(astResult);
  25892. }
  25893. });
  25894. return result;
  25895. }
  25896. exports.htmlVisitAll = htmlVisitAll;
  25897. /***/ },
  25898. /* 170 */
  25899. /***/ function(module, exports, __webpack_require__) {
  25900. var __extends = (this && this.__extends) || function (d, b) {
  25901. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  25902. function __() { this.constructor = d; }
  25903. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  25904. };
  25905. var lang_1 = __webpack_require__(5);
  25906. var collection_1 = __webpack_require__(12);
  25907. var parse_util_1 = __webpack_require__(171);
  25908. var html_tags_1 = __webpack_require__(172);
  25909. (function (HtmlTokenType) {
  25910. HtmlTokenType[HtmlTokenType["TAG_OPEN_START"] = 0] = "TAG_OPEN_START";
  25911. HtmlTokenType[HtmlTokenType["TAG_OPEN_END"] = 1] = "TAG_OPEN_END";
  25912. HtmlTokenType[HtmlTokenType["TAG_OPEN_END_VOID"] = 2] = "TAG_OPEN_END_VOID";
  25913. HtmlTokenType[HtmlTokenType["TAG_CLOSE"] = 3] = "TAG_CLOSE";
  25914. HtmlTokenType[HtmlTokenType["TEXT"] = 4] = "TEXT";
  25915. HtmlTokenType[HtmlTokenType["ESCAPABLE_RAW_TEXT"] = 5] = "ESCAPABLE_RAW_TEXT";
  25916. HtmlTokenType[HtmlTokenType["RAW_TEXT"] = 6] = "RAW_TEXT";
  25917. HtmlTokenType[HtmlTokenType["COMMENT_START"] = 7] = "COMMENT_START";
  25918. HtmlTokenType[HtmlTokenType["COMMENT_END"] = 8] = "COMMENT_END";
  25919. HtmlTokenType[HtmlTokenType["CDATA_START"] = 9] = "CDATA_START";
  25920. HtmlTokenType[HtmlTokenType["CDATA_END"] = 10] = "CDATA_END";
  25921. HtmlTokenType[HtmlTokenType["ATTR_NAME"] = 11] = "ATTR_NAME";
  25922. HtmlTokenType[HtmlTokenType["ATTR_VALUE"] = 12] = "ATTR_VALUE";
  25923. HtmlTokenType[HtmlTokenType["DOC_TYPE"] = 13] = "DOC_TYPE";
  25924. HtmlTokenType[HtmlTokenType["EOF"] = 14] = "EOF";
  25925. })(exports.HtmlTokenType || (exports.HtmlTokenType = {}));
  25926. var HtmlTokenType = exports.HtmlTokenType;
  25927. var HtmlToken = (function () {
  25928. function HtmlToken(type, parts, sourceSpan) {
  25929. this.type = type;
  25930. this.parts = parts;
  25931. this.sourceSpan = sourceSpan;
  25932. }
  25933. return HtmlToken;
  25934. })();
  25935. exports.HtmlToken = HtmlToken;
  25936. var HtmlTokenError = (function (_super) {
  25937. __extends(HtmlTokenError, _super);
  25938. function HtmlTokenError(errorMsg, tokenType, location) {
  25939. _super.call(this, location, errorMsg);
  25940. this.tokenType = tokenType;
  25941. }
  25942. return HtmlTokenError;
  25943. })(parse_util_1.ParseError);
  25944. exports.HtmlTokenError = HtmlTokenError;
  25945. var HtmlTokenizeResult = (function () {
  25946. function HtmlTokenizeResult(tokens, errors) {
  25947. this.tokens = tokens;
  25948. this.errors = errors;
  25949. }
  25950. return HtmlTokenizeResult;
  25951. })();
  25952. exports.HtmlTokenizeResult = HtmlTokenizeResult;
  25953. function tokenizeHtml(sourceContent, sourceUrl) {
  25954. return new _HtmlTokenizer(new parse_util_1.ParseSourceFile(sourceContent, sourceUrl)).tokenize();
  25955. }
  25956. exports.tokenizeHtml = tokenizeHtml;
  25957. var $EOF = 0;
  25958. var $TAB = 9;
  25959. var $LF = 10;
  25960. var $FF = 12;
  25961. var $CR = 13;
  25962. var $SPACE = 32;
  25963. var $BANG = 33;
  25964. var $DQ = 34;
  25965. var $HASH = 35;
  25966. var $$ = 36;
  25967. var $AMPERSAND = 38;
  25968. var $SQ = 39;
  25969. var $MINUS = 45;
  25970. var $SLASH = 47;
  25971. var $0 = 48;
  25972. var $SEMICOLON = 59;
  25973. var $9 = 57;
  25974. var $COLON = 58;
  25975. var $LT = 60;
  25976. var $EQ = 61;
  25977. var $GT = 62;
  25978. var $QUESTION = 63;
  25979. var $A = 65;
  25980. var $Z = 90;
  25981. var $LBRACKET = 91;
  25982. var $RBRACKET = 93;
  25983. var $a = 97;
  25984. var $f = 102;
  25985. var $z = 122;
  25986. var $x = 120;
  25987. var $NBSP = 160;
  25988. var CR_OR_CRLF_REGEXP = /\r\n?/g;
  25989. function unexpectedCharacterErrorMsg(charCode) {
  25990. var char = charCode === $EOF ? 'EOF' : lang_1.StringWrapper.fromCharCode(charCode);
  25991. return "Unexpected character \"" + char + "\"";
  25992. }
  25993. function unknownEntityErrorMsg(entitySrc) {
  25994. return "Unknown entity \"" + entitySrc + "\" - use the \"&#<decimal>;\" or \"&#x<hex>;\" syntax";
  25995. }
  25996. var ControlFlowError = (function () {
  25997. function ControlFlowError(error) {
  25998. this.error = error;
  25999. }
  26000. return ControlFlowError;
  26001. })();
  26002. // See http://www.w3.org/TR/html51/syntax.html#writing
  26003. var _HtmlTokenizer = (function () {
  26004. function _HtmlTokenizer(file) {
  26005. this.file = file;
  26006. // Note: this is always lowercase!
  26007. this.peek = -1;
  26008. this.index = -1;
  26009. this.line = 0;
  26010. this.column = -1;
  26011. this.tokens = [];
  26012. this.errors = [];
  26013. this.input = file.content;
  26014. this.inputLowercase = file.content.toLowerCase();
  26015. this.length = file.content.length;
  26016. this._advance();
  26017. }
  26018. _HtmlTokenizer.prototype._processCarriageReturns = function (content) {
  26019. // http://www.w3.org/TR/html5/syntax.html#preprocessing-the-input-stream
  26020. // In order to keep the original position in the source, we can not pre-process it.
  26021. // Instead CRs are processed right before instantiating the tokens.
  26022. return lang_1.StringWrapper.replaceAll(content, CR_OR_CRLF_REGEXP, '\n');
  26023. };
  26024. _HtmlTokenizer.prototype.tokenize = function () {
  26025. while (this.peek !== $EOF) {
  26026. var start = this._getLocation();
  26027. try {
  26028. if (this._attemptChar($LT)) {
  26029. if (this._attemptChar($BANG)) {
  26030. if (this._attemptChar($LBRACKET)) {
  26031. this._consumeCdata(start);
  26032. }
  26033. else if (this._attemptChar($MINUS)) {
  26034. this._consumeComment(start);
  26035. }
  26036. else {
  26037. this._consumeDocType(start);
  26038. }
  26039. }
  26040. else if (this._attemptChar($SLASH)) {
  26041. this._consumeTagClose(start);
  26042. }
  26043. else {
  26044. this._consumeTagOpen(start);
  26045. }
  26046. }
  26047. else {
  26048. this._consumeText();
  26049. }
  26050. }
  26051. catch (e) {
  26052. if (e instanceof ControlFlowError) {
  26053. this.errors.push(e.error);
  26054. }
  26055. else {
  26056. throw e;
  26057. }
  26058. }
  26059. }
  26060. this._beginToken(HtmlTokenType.EOF);
  26061. this._endToken([]);
  26062. return new HtmlTokenizeResult(mergeTextTokens(this.tokens), this.errors);
  26063. };
  26064. _HtmlTokenizer.prototype._getLocation = function () {
  26065. return new parse_util_1.ParseLocation(this.file, this.index, this.line, this.column);
  26066. };
  26067. _HtmlTokenizer.prototype._beginToken = function (type, start) {
  26068. if (start === void 0) { start = null; }
  26069. if (lang_1.isBlank(start)) {
  26070. start = this._getLocation();
  26071. }
  26072. this.currentTokenStart = start;
  26073. this.currentTokenType = type;
  26074. };
  26075. _HtmlTokenizer.prototype._endToken = function (parts, end) {
  26076. if (end === void 0) { end = null; }
  26077. if (lang_1.isBlank(end)) {
  26078. end = this._getLocation();
  26079. }
  26080. var token = new HtmlToken(this.currentTokenType, parts, new parse_util_1.ParseSourceSpan(this.currentTokenStart, end));
  26081. this.tokens.push(token);
  26082. this.currentTokenStart = null;
  26083. this.currentTokenType = null;
  26084. return token;
  26085. };
  26086. _HtmlTokenizer.prototype._createError = function (msg, position) {
  26087. var error = new HtmlTokenError(msg, this.currentTokenType, position);
  26088. this.currentTokenStart = null;
  26089. this.currentTokenType = null;
  26090. return new ControlFlowError(error);
  26091. };
  26092. _HtmlTokenizer.prototype._advance = function () {
  26093. if (this.index >= this.length) {
  26094. throw this._createError(unexpectedCharacterErrorMsg($EOF), this._getLocation());
  26095. }
  26096. if (this.peek === $LF) {
  26097. this.line++;
  26098. this.column = 0;
  26099. }
  26100. else if (this.peek !== $LF && this.peek !== $CR) {
  26101. this.column++;
  26102. }
  26103. this.index++;
  26104. this.peek = this.index >= this.length ? $EOF : lang_1.StringWrapper.charCodeAt(this.inputLowercase, this.index);
  26105. };
  26106. _HtmlTokenizer.prototype._attemptChar = function (charCode) {
  26107. if (this.peek === charCode) {
  26108. this._advance();
  26109. return true;
  26110. }
  26111. return false;
  26112. };
  26113. _HtmlTokenizer.prototype._requireChar = function (charCode) {
  26114. var location = this._getLocation();
  26115. if (!this._attemptChar(charCode)) {
  26116. throw this._createError(unexpectedCharacterErrorMsg(this.peek), location);
  26117. }
  26118. };
  26119. _HtmlTokenizer.prototype._attemptChars = function (chars) {
  26120. for (var i = 0; i < chars.length; i++) {
  26121. if (!this._attemptChar(lang_1.StringWrapper.charCodeAt(chars, i))) {
  26122. return false;
  26123. }
  26124. }
  26125. return true;
  26126. };
  26127. _HtmlTokenizer.prototype._requireChars = function (chars) {
  26128. var location = this._getLocation();
  26129. if (!this._attemptChars(chars)) {
  26130. throw this._createError(unexpectedCharacterErrorMsg(this.peek), location);
  26131. }
  26132. };
  26133. _HtmlTokenizer.prototype._attemptUntilFn = function (predicate) {
  26134. while (!predicate(this.peek)) {
  26135. this._advance();
  26136. }
  26137. };
  26138. _HtmlTokenizer.prototype._requireUntilFn = function (predicate, len) {
  26139. var start = this._getLocation();
  26140. this._attemptUntilFn(predicate);
  26141. if (this.index - start.offset < len) {
  26142. throw this._createError(unexpectedCharacterErrorMsg(this.peek), start);
  26143. }
  26144. };
  26145. _HtmlTokenizer.prototype._attemptUntilChar = function (char) {
  26146. while (this.peek !== char) {
  26147. this._advance();
  26148. }
  26149. };
  26150. _HtmlTokenizer.prototype._readChar = function (decodeEntities) {
  26151. if (decodeEntities && this.peek === $AMPERSAND) {
  26152. return this._decodeEntity();
  26153. }
  26154. else {
  26155. var index = this.index;
  26156. this._advance();
  26157. return this.input[index];
  26158. }
  26159. };
  26160. _HtmlTokenizer.prototype._decodeEntity = function () {
  26161. var start = this._getLocation();
  26162. this._advance();
  26163. if (this._attemptChar($HASH)) {
  26164. var isHex = this._attemptChar($x);
  26165. var numberStart = this._getLocation().offset;
  26166. this._attemptUntilFn(isDigitEntityEnd);
  26167. if (this.peek != $SEMICOLON) {
  26168. throw this._createError(unexpectedCharacterErrorMsg(this.peek), this._getLocation());
  26169. }
  26170. this._advance();
  26171. var strNum = this.input.substring(numberStart, this.index - 1);
  26172. try {
  26173. var charCode = lang_1.NumberWrapper.parseInt(strNum, isHex ? 16 : 10);
  26174. return lang_1.StringWrapper.fromCharCode(charCode);
  26175. }
  26176. catch (e) {
  26177. var entity = this.input.substring(start.offset + 1, this.index - 1);
  26178. throw this._createError(unknownEntityErrorMsg(entity), start);
  26179. }
  26180. }
  26181. else {
  26182. var startPosition = this._savePosition();
  26183. this._attemptUntilFn(isNamedEntityEnd);
  26184. if (this.peek != $SEMICOLON) {
  26185. this._restorePosition(startPosition);
  26186. return '&';
  26187. }
  26188. this._advance();
  26189. var name_1 = this.input.substring(start.offset + 1, this.index - 1);
  26190. var char = html_tags_1.NAMED_ENTITIES[name_1];
  26191. if (lang_1.isBlank(char)) {
  26192. throw this._createError(unknownEntityErrorMsg(name_1), start);
  26193. }
  26194. return char;
  26195. }
  26196. };
  26197. _HtmlTokenizer.prototype._consumeRawText = function (decodeEntities, firstCharOfEnd, attemptEndRest) {
  26198. var tagCloseStart;
  26199. var textStart = this._getLocation();
  26200. this._beginToken(decodeEntities ? HtmlTokenType.ESCAPABLE_RAW_TEXT : HtmlTokenType.RAW_TEXT, textStart);
  26201. var parts = [];
  26202. while (true) {
  26203. tagCloseStart = this._getLocation();
  26204. if (this._attemptChar(firstCharOfEnd) && attemptEndRest()) {
  26205. break;
  26206. }
  26207. if (this.index > tagCloseStart.offset) {
  26208. parts.push(this.input.substring(tagCloseStart.offset, this.index));
  26209. }
  26210. while (this.peek !== firstCharOfEnd) {
  26211. parts.push(this._readChar(decodeEntities));
  26212. }
  26213. }
  26214. return this._endToken([this._processCarriageReturns(parts.join(''))], tagCloseStart);
  26215. };
  26216. _HtmlTokenizer.prototype._consumeComment = function (start) {
  26217. var _this = this;
  26218. this._beginToken(HtmlTokenType.COMMENT_START, start);
  26219. this._requireChar($MINUS);
  26220. this._endToken([]);
  26221. var textToken = this._consumeRawText(false, $MINUS, function () { return _this._attemptChars('->'); });
  26222. this._beginToken(HtmlTokenType.COMMENT_END, textToken.sourceSpan.end);
  26223. this._endToken([]);
  26224. };
  26225. _HtmlTokenizer.prototype._consumeCdata = function (start) {
  26226. var _this = this;
  26227. this._beginToken(HtmlTokenType.CDATA_START, start);
  26228. this._requireChars('cdata[');
  26229. this._endToken([]);
  26230. var textToken = this._consumeRawText(false, $RBRACKET, function () { return _this._attemptChars(']>'); });
  26231. this._beginToken(HtmlTokenType.CDATA_END, textToken.sourceSpan.end);
  26232. this._endToken([]);
  26233. };
  26234. _HtmlTokenizer.prototype._consumeDocType = function (start) {
  26235. this._beginToken(HtmlTokenType.DOC_TYPE, start);
  26236. this._attemptUntilChar($GT);
  26237. this._advance();
  26238. this._endToken([this.input.substring(start.offset + 2, this.index - 1)]);
  26239. };
  26240. _HtmlTokenizer.prototype._consumePrefixAndName = function () {
  26241. var nameOrPrefixStart = this.index;
  26242. var prefix = null;
  26243. while (this.peek !== $COLON && !isPrefixEnd(this.peek)) {
  26244. this._advance();
  26245. }
  26246. var nameStart;
  26247. if (this.peek === $COLON) {
  26248. this._advance();
  26249. prefix = this.input.substring(nameOrPrefixStart, this.index - 1);
  26250. nameStart = this.index;
  26251. }
  26252. else {
  26253. nameStart = nameOrPrefixStart;
  26254. }
  26255. this._requireUntilFn(isNameEnd, this.index === nameStart ? 1 : 0);
  26256. var name = this.input.substring(nameStart, this.index);
  26257. return [prefix, name];
  26258. };
  26259. _HtmlTokenizer.prototype._consumeTagOpen = function (start) {
  26260. var savedPos = this._savePosition();
  26261. var lowercaseTagName;
  26262. try {
  26263. if (!isAsciiLetter(this.peek)) {
  26264. throw this._createError(unexpectedCharacterErrorMsg(this.peek), this._getLocation());
  26265. }
  26266. var nameStart = this.index;
  26267. this._consumeTagOpenStart(start);
  26268. lowercaseTagName = this.inputLowercase.substring(nameStart, this.index);
  26269. this._attemptUntilFn(isNotWhitespace);
  26270. while (this.peek !== $SLASH && this.peek !== $GT) {
  26271. this._consumeAttributeName();
  26272. this._attemptUntilFn(isNotWhitespace);
  26273. if (this._attemptChar($EQ)) {
  26274. this._attemptUntilFn(isNotWhitespace);
  26275. this._consumeAttributeValue();
  26276. }
  26277. this._attemptUntilFn(isNotWhitespace);
  26278. }
  26279. this._consumeTagOpenEnd();
  26280. }
  26281. catch (e) {
  26282. if (e instanceof ControlFlowError) {
  26283. // When the start tag is invalid, assume we want a "<"
  26284. this._restorePosition(savedPos);
  26285. // Back to back text tokens are merged at the end
  26286. this._beginToken(HtmlTokenType.TEXT, start);
  26287. this._endToken(['<']);
  26288. return;
  26289. }
  26290. throw e;
  26291. }
  26292. var contentTokenType = html_tags_1.getHtmlTagDefinition(lowercaseTagName).contentType;
  26293. if (contentTokenType === html_tags_1.HtmlTagContentType.RAW_TEXT) {
  26294. this._consumeRawTextWithTagClose(lowercaseTagName, false);
  26295. }
  26296. else if (contentTokenType === html_tags_1.HtmlTagContentType.ESCAPABLE_RAW_TEXT) {
  26297. this._consumeRawTextWithTagClose(lowercaseTagName, true);
  26298. }
  26299. };
  26300. _HtmlTokenizer.prototype._consumeRawTextWithTagClose = function (lowercaseTagName, decodeEntities) {
  26301. var _this = this;
  26302. var textToken = this._consumeRawText(decodeEntities, $LT, function () {
  26303. if (!_this._attemptChar($SLASH))
  26304. return false;
  26305. _this._attemptUntilFn(isNotWhitespace);
  26306. if (!_this._attemptChars(lowercaseTagName))
  26307. return false;
  26308. _this._attemptUntilFn(isNotWhitespace);
  26309. if (!_this._attemptChar($GT))
  26310. return false;
  26311. return true;
  26312. });
  26313. this._beginToken(HtmlTokenType.TAG_CLOSE, textToken.sourceSpan.end);
  26314. this._endToken([null, lowercaseTagName]);
  26315. };
  26316. _HtmlTokenizer.prototype._consumeTagOpenStart = function (start) {
  26317. this._beginToken(HtmlTokenType.TAG_OPEN_START, start);
  26318. var parts = this._consumePrefixAndName();
  26319. this._endToken(parts);
  26320. };
  26321. _HtmlTokenizer.prototype._consumeAttributeName = function () {
  26322. this._beginToken(HtmlTokenType.ATTR_NAME);
  26323. var prefixAndName = this._consumePrefixAndName();
  26324. this._endToken(prefixAndName);
  26325. };
  26326. _HtmlTokenizer.prototype._consumeAttributeValue = function () {
  26327. this._beginToken(HtmlTokenType.ATTR_VALUE);
  26328. var value;
  26329. if (this.peek === $SQ || this.peek === $DQ) {
  26330. var quoteChar = this.peek;
  26331. this._advance();
  26332. var parts = [];
  26333. while (this.peek !== quoteChar) {
  26334. parts.push(this._readChar(true));
  26335. }
  26336. value = parts.join('');
  26337. this._advance();
  26338. }
  26339. else {
  26340. var valueStart = this.index;
  26341. this._requireUntilFn(isNameEnd, 1);
  26342. value = this.input.substring(valueStart, this.index);
  26343. }
  26344. this._endToken([this._processCarriageReturns(value)]);
  26345. };
  26346. _HtmlTokenizer.prototype._consumeTagOpenEnd = function () {
  26347. var tokenType = this._attemptChar($SLASH) ? HtmlTokenType.TAG_OPEN_END_VOID : HtmlTokenType.TAG_OPEN_END;
  26348. this._beginToken(tokenType);
  26349. this._requireChar($GT);
  26350. this._endToken([]);
  26351. };
  26352. _HtmlTokenizer.prototype._consumeTagClose = function (start) {
  26353. this._beginToken(HtmlTokenType.TAG_CLOSE, start);
  26354. this._attemptUntilFn(isNotWhitespace);
  26355. var prefixAndName;
  26356. prefixAndName = this._consumePrefixAndName();
  26357. this._attemptUntilFn(isNotWhitespace);
  26358. this._requireChar($GT);
  26359. this._endToken(prefixAndName);
  26360. };
  26361. _HtmlTokenizer.prototype._consumeText = function () {
  26362. var start = this._getLocation();
  26363. this._beginToken(HtmlTokenType.TEXT, start);
  26364. var parts = [this._readChar(true)];
  26365. while (!isTextEnd(this.peek)) {
  26366. parts.push(this._readChar(true));
  26367. }
  26368. this._endToken([this._processCarriageReturns(parts.join(''))]);
  26369. };
  26370. _HtmlTokenizer.prototype._savePosition = function () {
  26371. return [this.peek, this.index, this.column, this.line, this.tokens.length];
  26372. };
  26373. _HtmlTokenizer.prototype._restorePosition = function (position) {
  26374. this.peek = position[0];
  26375. this.index = position[1];
  26376. this.column = position[2];
  26377. this.line = position[3];
  26378. var nbTokens = position[4];
  26379. if (nbTokens < this.tokens.length) {
  26380. // remove any extra tokens
  26381. this.tokens = collection_1.ListWrapper.slice(this.tokens, 0, nbTokens);
  26382. }
  26383. };
  26384. return _HtmlTokenizer;
  26385. })();
  26386. function isNotWhitespace(code) {
  26387. return !isWhitespace(code) || code === $EOF;
  26388. }
  26389. function isWhitespace(code) {
  26390. return (code >= $TAB && code <= $SPACE) || (code === $NBSP);
  26391. }
  26392. function isNameEnd(code) {
  26393. return isWhitespace(code) || code === $GT || code === $SLASH || code === $SQ || code === $DQ ||
  26394. code === $EQ;
  26395. }
  26396. function isPrefixEnd(code) {
  26397. return (code < $a || $z < code) && (code < $A || $Z < code) && (code < $0 || code > $9);
  26398. }
  26399. function isDigitEntityEnd(code) {
  26400. return code == $SEMICOLON || code == $EOF || !isAsciiHexDigit(code);
  26401. }
  26402. function isNamedEntityEnd(code) {
  26403. return code == $SEMICOLON || code == $EOF || !isAsciiLetter(code);
  26404. }
  26405. function isTextEnd(code) {
  26406. return code === $LT || code === $EOF;
  26407. }
  26408. function isAsciiLetter(code) {
  26409. return code >= $a && code <= $z;
  26410. }
  26411. function isAsciiHexDigit(code) {
  26412. return code >= $a && code <= $f || code >= $0 && code <= $9;
  26413. }
  26414. function mergeTextTokens(srcTokens) {
  26415. var dstTokens = [];
  26416. var lastDstToken;
  26417. for (var i = 0; i < srcTokens.length; i++) {
  26418. var token = srcTokens[i];
  26419. if (lang_1.isPresent(lastDstToken) && lastDstToken.type == HtmlTokenType.TEXT &&
  26420. token.type == HtmlTokenType.TEXT) {
  26421. lastDstToken.parts[0] += token.parts[0];
  26422. lastDstToken.sourceSpan.end = token.sourceSpan.end;
  26423. }
  26424. else {
  26425. lastDstToken = token;
  26426. dstTokens.push(lastDstToken);
  26427. }
  26428. }
  26429. return dstTokens;
  26430. }
  26431. /***/ },
  26432. /* 171 */
  26433. /***/ function(module, exports) {
  26434. var ParseLocation = (function () {
  26435. function ParseLocation(file, offset, line, col) {
  26436. this.file = file;
  26437. this.offset = offset;
  26438. this.line = line;
  26439. this.col = col;
  26440. }
  26441. ParseLocation.prototype.toString = function () { return this.file.url + "@" + this.line + ":" + this.col; };
  26442. return ParseLocation;
  26443. })();
  26444. exports.ParseLocation = ParseLocation;
  26445. var ParseSourceFile = (function () {
  26446. function ParseSourceFile(content, url) {
  26447. this.content = content;
  26448. this.url = url;
  26449. }
  26450. return ParseSourceFile;
  26451. })();
  26452. exports.ParseSourceFile = ParseSourceFile;
  26453. var ParseError = (function () {
  26454. function ParseError(location, msg) {
  26455. this.location = location;
  26456. this.msg = msg;
  26457. }
  26458. ParseError.prototype.toString = function () {
  26459. var source = this.location.file.content;
  26460. var ctxStart = this.location.offset;
  26461. if (ctxStart > source.length - 1) {
  26462. ctxStart = source.length - 1;
  26463. }
  26464. var ctxEnd = ctxStart;
  26465. var ctxLen = 0;
  26466. var ctxLines = 0;
  26467. while (ctxLen < 100 && ctxStart > 0) {
  26468. ctxStart--;
  26469. ctxLen++;
  26470. if (source[ctxStart] == "\n") {
  26471. if (++ctxLines == 3) {
  26472. break;
  26473. }
  26474. }
  26475. }
  26476. ctxLen = 0;
  26477. ctxLines = 0;
  26478. while (ctxLen < 100 && ctxEnd < source.length - 1) {
  26479. ctxEnd++;
  26480. ctxLen++;
  26481. if (source[ctxEnd] == "\n") {
  26482. if (++ctxLines == 3) {
  26483. break;
  26484. }
  26485. }
  26486. }
  26487. var context = source.substring(ctxStart, this.location.offset) + '[ERROR ->]' +
  26488. source.substring(this.location.offset, ctxEnd + 1);
  26489. return this.msg + " (\"" + context + "\"): " + this.location;
  26490. };
  26491. return ParseError;
  26492. })();
  26493. exports.ParseError = ParseError;
  26494. var ParseSourceSpan = (function () {
  26495. function ParseSourceSpan(start, end) {
  26496. this.start = start;
  26497. this.end = end;
  26498. }
  26499. ParseSourceSpan.prototype.toString = function () {
  26500. return this.start.file.content.substring(this.start.offset, this.end.offset);
  26501. };
  26502. return ParseSourceSpan;
  26503. })();
  26504. exports.ParseSourceSpan = ParseSourceSpan;
  26505. /***/ },
  26506. /* 172 */
  26507. /***/ function(module, exports, __webpack_require__) {
  26508. var lang_1 = __webpack_require__(5);
  26509. // see http://www.w3.org/TR/html51/syntax.html#named-character-references
  26510. // see https://html.spec.whatwg.org/multipage/entities.json
  26511. // This list is not exhaustive to keep the compiler footprint low.
  26512. // The `&#123;` / `&#x1ab;` syntax should be used when the named character reference does not exist.
  26513. exports.NAMED_ENTITIES = lang_1.CONST_EXPR({
  26514. 'Aacute': '\u00C1',
  26515. 'aacute': '\u00E1',
  26516. 'Acirc': '\u00C2',
  26517. 'acirc': '\u00E2',
  26518. 'acute': '\u00B4',
  26519. 'AElig': '\u00C6',
  26520. 'aelig': '\u00E6',
  26521. 'Agrave': '\u00C0',
  26522. 'agrave': '\u00E0',
  26523. 'alefsym': '\u2135',
  26524. 'Alpha': '\u0391',
  26525. 'alpha': '\u03B1',
  26526. 'amp': '&',
  26527. 'and': '\u2227',
  26528. 'ang': '\u2220',
  26529. 'apos': '\u0027',
  26530. 'Aring': '\u00C5',
  26531. 'aring': '\u00E5',
  26532. 'asymp': '\u2248',
  26533. 'Atilde': '\u00C3',
  26534. 'atilde': '\u00E3',
  26535. 'Auml': '\u00C4',
  26536. 'auml': '\u00E4',
  26537. 'bdquo': '\u201E',
  26538. 'Beta': '\u0392',
  26539. 'beta': '\u03B2',
  26540. 'brvbar': '\u00A6',
  26541. 'bull': '\u2022',
  26542. 'cap': '\u2229',
  26543. 'Ccedil': '\u00C7',
  26544. 'ccedil': '\u00E7',
  26545. 'cedil': '\u00B8',
  26546. 'cent': '\u00A2',
  26547. 'Chi': '\u03A7',
  26548. 'chi': '\u03C7',
  26549. 'circ': '\u02C6',
  26550. 'clubs': '\u2663',
  26551. 'cong': '\u2245',
  26552. 'copy': '\u00A9',
  26553. 'crarr': '\u21B5',
  26554. 'cup': '\u222A',
  26555. 'curren': '\u00A4',
  26556. 'dagger': '\u2020',
  26557. 'Dagger': '\u2021',
  26558. 'darr': '\u2193',
  26559. 'dArr': '\u21D3',
  26560. 'deg': '\u00B0',
  26561. 'Delta': '\u0394',
  26562. 'delta': '\u03B4',
  26563. 'diams': '\u2666',
  26564. 'divide': '\u00F7',
  26565. 'Eacute': '\u00C9',
  26566. 'eacute': '\u00E9',
  26567. 'Ecirc': '\u00CA',
  26568. 'ecirc': '\u00EA',
  26569. 'Egrave': '\u00C8',
  26570. 'egrave': '\u00E8',
  26571. 'empty': '\u2205',
  26572. 'emsp': '\u2003',
  26573. 'ensp': '\u2002',
  26574. 'Epsilon': '\u0395',
  26575. 'epsilon': '\u03B5',
  26576. 'equiv': '\u2261',
  26577. 'Eta': '\u0397',
  26578. 'eta': '\u03B7',
  26579. 'ETH': '\u00D0',
  26580. 'eth': '\u00F0',
  26581. 'Euml': '\u00CB',
  26582. 'euml': '\u00EB',
  26583. 'euro': '\u20AC',
  26584. 'exist': '\u2203',
  26585. 'fnof': '\u0192',
  26586. 'forall': '\u2200',
  26587. 'frac12': '\u00BD',
  26588. 'frac14': '\u00BC',
  26589. 'frac34': '\u00BE',
  26590. 'frasl': '\u2044',
  26591. 'Gamma': '\u0393',
  26592. 'gamma': '\u03B3',
  26593. 'ge': '\u2265',
  26594. 'gt': '>',
  26595. 'harr': '\u2194',
  26596. 'hArr': '\u21D4',
  26597. 'hearts': '\u2665',
  26598. 'hellip': '\u2026',
  26599. 'Iacute': '\u00CD',
  26600. 'iacute': '\u00ED',
  26601. 'Icirc': '\u00CE',
  26602. 'icirc': '\u00EE',
  26603. 'iexcl': '\u00A1',
  26604. 'Igrave': '\u00CC',
  26605. 'igrave': '\u00EC',
  26606. 'image': '\u2111',
  26607. 'infin': '\u221E',
  26608. 'int': '\u222B',
  26609. 'Iota': '\u0399',
  26610. 'iota': '\u03B9',
  26611. 'iquest': '\u00BF',
  26612. 'isin': '\u2208',
  26613. 'Iuml': '\u00CF',
  26614. 'iuml': '\u00EF',
  26615. 'Kappa': '\u039A',
  26616. 'kappa': '\u03BA',
  26617. 'Lambda': '\u039B',
  26618. 'lambda': '\u03BB',
  26619. 'lang': '\u27E8',
  26620. 'laquo': '\u00AB',
  26621. 'larr': '\u2190',
  26622. 'lArr': '\u21D0',
  26623. 'lceil': '\u2308',
  26624. 'ldquo': '\u201C',
  26625. 'le': '\u2264',
  26626. 'lfloor': '\u230A',
  26627. 'lowast': '\u2217',
  26628. 'loz': '\u25CA',
  26629. 'lrm': '\u200E',
  26630. 'lsaquo': '\u2039',
  26631. 'lsquo': '\u2018',
  26632. 'lt': '<',
  26633. 'macr': '\u00AF',
  26634. 'mdash': '\u2014',
  26635. 'micro': '\u00B5',
  26636. 'middot': '\u00B7',
  26637. 'minus': '\u2212',
  26638. 'Mu': '\u039C',
  26639. 'mu': '\u03BC',
  26640. 'nabla': '\u2207',
  26641. 'nbsp': '\u00A0',
  26642. 'ndash': '\u2013',
  26643. 'ne': '\u2260',
  26644. 'ni': '\u220B',
  26645. 'not': '\u00AC',
  26646. 'notin': '\u2209',
  26647. 'nsub': '\u2284',
  26648. 'Ntilde': '\u00D1',
  26649. 'ntilde': '\u00F1',
  26650. 'Nu': '\u039D',
  26651. 'nu': '\u03BD',
  26652. 'Oacute': '\u00D3',
  26653. 'oacute': '\u00F3',
  26654. 'Ocirc': '\u00D4',
  26655. 'ocirc': '\u00F4',
  26656. 'OElig': '\u0152',
  26657. 'oelig': '\u0153',
  26658. 'Ograve': '\u00D2',
  26659. 'ograve': '\u00F2',
  26660. 'oline': '\u203E',
  26661. 'Omega': '\u03A9',
  26662. 'omega': '\u03C9',
  26663. 'Omicron': '\u039F',
  26664. 'omicron': '\u03BF',
  26665. 'oplus': '\u2295',
  26666. 'or': '\u2228',
  26667. 'ordf': '\u00AA',
  26668. 'ordm': '\u00BA',
  26669. 'Oslash': '\u00D8',
  26670. 'oslash': '\u00F8',
  26671. 'Otilde': '\u00D5',
  26672. 'otilde': '\u00F5',
  26673. 'otimes': '\u2297',
  26674. 'Ouml': '\u00D6',
  26675. 'ouml': '\u00F6',
  26676. 'para': '\u00B6',
  26677. 'permil': '\u2030',
  26678. 'perp': '\u22A5',
  26679. 'Phi': '\u03A6',
  26680. 'phi': '\u03C6',
  26681. 'Pi': '\u03A0',
  26682. 'pi': '\u03C0',
  26683. 'piv': '\u03D6',
  26684. 'plusmn': '\u00B1',
  26685. 'pound': '\u00A3',
  26686. 'prime': '\u2032',
  26687. 'Prime': '\u2033',
  26688. 'prod': '\u220F',
  26689. 'prop': '\u221D',
  26690. 'Psi': '\u03A8',
  26691. 'psi': '\u03C8',
  26692. 'quot': '\u0022',
  26693. 'radic': '\u221A',
  26694. 'rang': '\u27E9',
  26695. 'raquo': '\u00BB',
  26696. 'rarr': '\u2192',
  26697. 'rArr': '\u21D2',
  26698. 'rceil': '\u2309',
  26699. 'rdquo': '\u201D',
  26700. 'real': '\u211C',
  26701. 'reg': '\u00AE',
  26702. 'rfloor': '\u230B',
  26703. 'Rho': '\u03A1',
  26704. 'rho': '\u03C1',
  26705. 'rlm': '\u200F',
  26706. 'rsaquo': '\u203A',
  26707. 'rsquo': '\u2019',
  26708. 'sbquo': '\u201A',
  26709. 'Scaron': '\u0160',
  26710. 'scaron': '\u0161',
  26711. 'sdot': '\u22C5',
  26712. 'sect': '\u00A7',
  26713. 'shy': '\u00AD',
  26714. 'Sigma': '\u03A3',
  26715. 'sigma': '\u03C3',
  26716. 'sigmaf': '\u03C2',
  26717. 'sim': '\u223C',
  26718. 'spades': '\u2660',
  26719. 'sub': '\u2282',
  26720. 'sube': '\u2286',
  26721. 'sum': '\u2211',
  26722. 'sup': '\u2283',
  26723. 'sup1': '\u00B9',
  26724. 'sup2': '\u00B2',
  26725. 'sup3': '\u00B3',
  26726. 'supe': '\u2287',
  26727. 'szlig': '\u00DF',
  26728. 'Tau': '\u03A4',
  26729. 'tau': '\u03C4',
  26730. 'there4': '\u2234',
  26731. 'Theta': '\u0398',
  26732. 'theta': '\u03B8',
  26733. 'thetasym': '\u03D1',
  26734. 'thinsp': '\u2009',
  26735. 'THORN': '\u00DE',
  26736. 'thorn': '\u00FE',
  26737. 'tilde': '\u02DC',
  26738. 'times': '\u00D7',
  26739. 'trade': '\u2122',
  26740. 'Uacute': '\u00DA',
  26741. 'uacute': '\u00FA',
  26742. 'uarr': '\u2191',
  26743. 'uArr': '\u21D1',
  26744. 'Ucirc': '\u00DB',
  26745. 'ucirc': '\u00FB',
  26746. 'Ugrave': '\u00D9',
  26747. 'ugrave': '\u00F9',
  26748. 'uml': '\u00A8',
  26749. 'upsih': '\u03D2',
  26750. 'Upsilon': '\u03A5',
  26751. 'upsilon': '\u03C5',
  26752. 'Uuml': '\u00DC',
  26753. 'uuml': '\u00FC',
  26754. 'weierp': '\u2118',
  26755. 'Xi': '\u039E',
  26756. 'xi': '\u03BE',
  26757. 'Yacute': '\u00DD',
  26758. 'yacute': '\u00FD',
  26759. 'yen': '\u00A5',
  26760. 'yuml': '\u00FF',
  26761. 'Yuml': '\u0178',
  26762. 'Zeta': '\u0396',
  26763. 'zeta': '\u03B6',
  26764. 'zwj': '\u200D',
  26765. 'zwnj': '\u200C',
  26766. });
  26767. (function (HtmlTagContentType) {
  26768. HtmlTagContentType[HtmlTagContentType["RAW_TEXT"] = 0] = "RAW_TEXT";
  26769. HtmlTagContentType[HtmlTagContentType["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT";
  26770. HtmlTagContentType[HtmlTagContentType["PARSABLE_DATA"] = 2] = "PARSABLE_DATA";
  26771. })(exports.HtmlTagContentType || (exports.HtmlTagContentType = {}));
  26772. var HtmlTagContentType = exports.HtmlTagContentType;
  26773. var HtmlTagDefinition = (function () {
  26774. function HtmlTagDefinition(_a) {
  26775. var _this = this;
  26776. var _b = _a === void 0 ? {} : _a, closedByChildren = _b.closedByChildren, requiredParents = _b.requiredParents, implicitNamespacePrefix = _b.implicitNamespacePrefix, contentType = _b.contentType, closedByParent = _b.closedByParent, isVoid = _b.isVoid, ignoreFirstLf = _b.ignoreFirstLf;
  26777. this.closedByChildren = {};
  26778. this.closedByParent = false;
  26779. if (lang_1.isPresent(closedByChildren) && closedByChildren.length > 0) {
  26780. closedByChildren.forEach(function (tagName) { return _this.closedByChildren[tagName] = true; });
  26781. }
  26782. this.isVoid = lang_1.normalizeBool(isVoid);
  26783. this.closedByParent = lang_1.normalizeBool(closedByParent) || this.isVoid;
  26784. if (lang_1.isPresent(requiredParents) && requiredParents.length > 0) {
  26785. this.requiredParents = {};
  26786. this.parentToAdd = requiredParents[0];
  26787. requiredParents.forEach(function (tagName) { return _this.requiredParents[tagName] = true; });
  26788. }
  26789. this.implicitNamespacePrefix = implicitNamespacePrefix;
  26790. this.contentType = lang_1.isPresent(contentType) ? contentType : HtmlTagContentType.PARSABLE_DATA;
  26791. this.ignoreFirstLf = lang_1.normalizeBool(ignoreFirstLf);
  26792. }
  26793. HtmlTagDefinition.prototype.requireExtraParent = function (currentParent) {
  26794. if (lang_1.isBlank(this.requiredParents)) {
  26795. return false;
  26796. }
  26797. if (lang_1.isBlank(currentParent)) {
  26798. return true;
  26799. }
  26800. var lcParent = currentParent.toLowerCase();
  26801. return this.requiredParents[lcParent] != true && lcParent != 'template';
  26802. };
  26803. HtmlTagDefinition.prototype.isClosedByChild = function (name) {
  26804. return this.isVoid || lang_1.normalizeBool(this.closedByChildren[name.toLowerCase()]);
  26805. };
  26806. return HtmlTagDefinition;
  26807. })();
  26808. exports.HtmlTagDefinition = HtmlTagDefinition;
  26809. // see http://www.w3.org/TR/html51/syntax.html#optional-tags
  26810. // This implementation does not fully conform to the HTML5 spec.
  26811. var TAG_DEFINITIONS = {
  26812. 'area': new HtmlTagDefinition({ isVoid: true }),
  26813. 'embed': new HtmlTagDefinition({ isVoid: true }),
  26814. 'link': new HtmlTagDefinition({ isVoid: true }),
  26815. 'img': new HtmlTagDefinition({ isVoid: true }),
  26816. 'input': new HtmlTagDefinition({ isVoid: true }),
  26817. 'param': new HtmlTagDefinition({ isVoid: true }),
  26818. 'hr': new HtmlTagDefinition({ isVoid: true }),
  26819. 'br': new HtmlTagDefinition({ isVoid: true }),
  26820. 'source': new HtmlTagDefinition({ isVoid: true }),
  26821. 'track': new HtmlTagDefinition({ isVoid: true }),
  26822. 'wbr': new HtmlTagDefinition({ isVoid: true }),
  26823. 'p': new HtmlTagDefinition({
  26824. closedByChildren: [
  26825. 'address',
  26826. 'article',
  26827. 'aside',
  26828. 'blockquote',
  26829. 'div',
  26830. 'dl',
  26831. 'fieldset',
  26832. 'footer',
  26833. 'form',
  26834. 'h1',
  26835. 'h2',
  26836. 'h3',
  26837. 'h4',
  26838. 'h5',
  26839. 'h6',
  26840. 'header',
  26841. 'hgroup',
  26842. 'hr',
  26843. 'main',
  26844. 'nav',
  26845. 'ol',
  26846. 'p',
  26847. 'pre',
  26848. 'section',
  26849. 'table',
  26850. 'ul'
  26851. ],
  26852. closedByParent: true
  26853. }),
  26854. 'thead': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'] }),
  26855. 'tbody': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'], closedByParent: true }),
  26856. 'tfoot': new HtmlTagDefinition({ closedByChildren: ['tbody'], closedByParent: true }),
  26857. 'tr': new HtmlTagDefinition({
  26858. closedByChildren: ['tr'],
  26859. requiredParents: ['tbody', 'tfoot', 'thead'],
  26860. closedByParent: true
  26861. }),
  26862. 'td': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }),
  26863. 'th': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }),
  26864. 'col': new HtmlTagDefinition({ requiredParents: ['colgroup'], isVoid: true }),
  26865. 'svg': new HtmlTagDefinition({ implicitNamespacePrefix: 'svg' }),
  26866. 'math': new HtmlTagDefinition({ implicitNamespacePrefix: 'math' }),
  26867. 'li': new HtmlTagDefinition({ closedByChildren: ['li'], closedByParent: true }),
  26868. 'dt': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'] }),
  26869. 'dd': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'], closedByParent: true }),
  26870. 'rb': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
  26871. 'rt': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
  26872. 'rtc': new HtmlTagDefinition({ closedByChildren: ['rb', 'rtc', 'rp'], closedByParent: true }),
  26873. 'rp': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
  26874. 'optgroup': new HtmlTagDefinition({ closedByChildren: ['optgroup'], closedByParent: true }),
  26875. 'option': new HtmlTagDefinition({ closedByChildren: ['option', 'optgroup'], closedByParent: true }),
  26876. 'pre': new HtmlTagDefinition({ ignoreFirstLf: true }),
  26877. 'listing': new HtmlTagDefinition({ ignoreFirstLf: true }),
  26878. 'style': new HtmlTagDefinition({ contentType: HtmlTagContentType.RAW_TEXT }),
  26879. 'script': new HtmlTagDefinition({ contentType: HtmlTagContentType.RAW_TEXT }),
  26880. 'title': new HtmlTagDefinition({ contentType: HtmlTagContentType.ESCAPABLE_RAW_TEXT }),
  26881. 'textarea': new HtmlTagDefinition({ contentType: HtmlTagContentType.ESCAPABLE_RAW_TEXT, ignoreFirstLf: true }),
  26882. };
  26883. var DEFAULT_TAG_DEFINITION = new HtmlTagDefinition();
  26884. function getHtmlTagDefinition(tagName) {
  26885. var result = TAG_DEFINITIONS[tagName.toLowerCase()];
  26886. return lang_1.isPresent(result) ? result : DEFAULT_TAG_DEFINITION;
  26887. }
  26888. exports.getHtmlTagDefinition = getHtmlTagDefinition;
  26889. var NS_PREFIX_RE = /^@([^:]+):(.+)/g;
  26890. function splitNsName(elementName) {
  26891. if (elementName[0] != '@') {
  26892. return [null, elementName];
  26893. }
  26894. var match = lang_1.RegExpWrapper.firstMatch(NS_PREFIX_RE, elementName);
  26895. return [match[1], match[2]];
  26896. }
  26897. exports.splitNsName = splitNsName;
  26898. function getNsPrefix(elementName) {
  26899. return splitNsName(elementName)[0];
  26900. }
  26901. exports.getNsPrefix = getNsPrefix;
  26902. /***/ },
  26903. /* 173 */
  26904. /***/ function(module, exports) {
  26905. var ElementSchemaRegistry = (function () {
  26906. function ElementSchemaRegistry() {
  26907. }
  26908. ElementSchemaRegistry.prototype.hasProperty = function (tagName, propName) { return true; };
  26909. ElementSchemaRegistry.prototype.getMappedPropName = function (propName) { return propName; };
  26910. return ElementSchemaRegistry;
  26911. })();
  26912. exports.ElementSchemaRegistry = ElementSchemaRegistry;
  26913. /***/ },
  26914. /* 174 */
  26915. /***/ function(module, exports, __webpack_require__) {
  26916. var lang_1 = __webpack_require__(5);
  26917. var html_tags_1 = __webpack_require__(172);
  26918. var NG_CONTENT_SELECT_ATTR = 'select';
  26919. var NG_CONTENT_ELEMENT = 'ng-content';
  26920. var LINK_ELEMENT = 'link';
  26921. var LINK_STYLE_REL_ATTR = 'rel';
  26922. var LINK_STYLE_HREF_ATTR = 'href';
  26923. var LINK_STYLE_REL_VALUE = 'stylesheet';
  26924. var STYLE_ELEMENT = 'style';
  26925. var SCRIPT_ELEMENT = 'script';
  26926. var NG_NON_BINDABLE_ATTR = 'ngNonBindable';
  26927. function preparseElement(ast) {
  26928. var selectAttr = null;
  26929. var hrefAttr = null;
  26930. var relAttr = null;
  26931. var nonBindable = false;
  26932. ast.attrs.forEach(function (attr) {
  26933. var lcAttrName = attr.name.toLowerCase();
  26934. if (lcAttrName == NG_CONTENT_SELECT_ATTR) {
  26935. selectAttr = attr.value;
  26936. }
  26937. else if (lcAttrName == LINK_STYLE_HREF_ATTR) {
  26938. hrefAttr = attr.value;
  26939. }
  26940. else if (lcAttrName == LINK_STYLE_REL_ATTR) {
  26941. relAttr = attr.value;
  26942. }
  26943. else if (attr.name == NG_NON_BINDABLE_ATTR) {
  26944. nonBindable = true;
  26945. }
  26946. });
  26947. selectAttr = normalizeNgContentSelect(selectAttr);
  26948. var nodeName = ast.name.toLowerCase();
  26949. var type = PreparsedElementType.OTHER;
  26950. if (html_tags_1.splitNsName(nodeName)[1] == NG_CONTENT_ELEMENT) {
  26951. type = PreparsedElementType.NG_CONTENT;
  26952. }
  26953. else if (nodeName == STYLE_ELEMENT) {
  26954. type = PreparsedElementType.STYLE;
  26955. }
  26956. else if (nodeName == SCRIPT_ELEMENT) {
  26957. type = PreparsedElementType.SCRIPT;
  26958. }
  26959. else if (nodeName == LINK_ELEMENT && relAttr == LINK_STYLE_REL_VALUE) {
  26960. type = PreparsedElementType.STYLESHEET;
  26961. }
  26962. return new PreparsedElement(type, selectAttr, hrefAttr, nonBindable);
  26963. }
  26964. exports.preparseElement = preparseElement;
  26965. (function (PreparsedElementType) {
  26966. PreparsedElementType[PreparsedElementType["NG_CONTENT"] = 0] = "NG_CONTENT";
  26967. PreparsedElementType[PreparsedElementType["STYLE"] = 1] = "STYLE";
  26968. PreparsedElementType[PreparsedElementType["STYLESHEET"] = 2] = "STYLESHEET";
  26969. PreparsedElementType[PreparsedElementType["SCRIPT"] = 3] = "SCRIPT";
  26970. PreparsedElementType[PreparsedElementType["OTHER"] = 4] = "OTHER";
  26971. })(exports.PreparsedElementType || (exports.PreparsedElementType = {}));
  26972. var PreparsedElementType = exports.PreparsedElementType;
  26973. var PreparsedElement = (function () {
  26974. function PreparsedElement(type, selectAttr, hrefAttr, nonBindable) {
  26975. this.type = type;
  26976. this.selectAttr = selectAttr;
  26977. this.hrefAttr = hrefAttr;
  26978. this.nonBindable = nonBindable;
  26979. }
  26980. return PreparsedElement;
  26981. })();
  26982. exports.PreparsedElement = PreparsedElement;
  26983. function normalizeNgContentSelect(selectAttr) {
  26984. if (lang_1.isBlank(selectAttr) || selectAttr.length === 0) {
  26985. return '*';
  26986. }
  26987. return selectAttr;
  26988. }
  26989. /***/ },
  26990. /* 175 */
  26991. /***/ function(module, exports, __webpack_require__) {
  26992. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  26993. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  26994. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  26995. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  26996. return c > 3 && r && Object.defineProperty(target, key, r), r;
  26997. };
  26998. var __metadata = (this && this.__metadata) || function (k, v) {
  26999. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  27000. };
  27001. var directive_metadata_1 = __webpack_require__(153);
  27002. var lang_1 = __webpack_require__(5);
  27003. var exceptions_1 = __webpack_require__(14);
  27004. var async_1 = __webpack_require__(60);
  27005. var xhr_1 = __webpack_require__(149);
  27006. var url_resolver_1 = __webpack_require__(148);
  27007. var style_url_resolver_1 = __webpack_require__(163);
  27008. var di_1 = __webpack_require__(6);
  27009. var view_1 = __webpack_require__(56);
  27010. var html_ast_1 = __webpack_require__(169);
  27011. var html_parser_1 = __webpack_require__(168);
  27012. var template_preparser_1 = __webpack_require__(174);
  27013. var TemplateNormalizer = (function () {
  27014. function TemplateNormalizer(_xhr, _urlResolver, _htmlParser) {
  27015. this._xhr = _xhr;
  27016. this._urlResolver = _urlResolver;
  27017. this._htmlParser = _htmlParser;
  27018. }
  27019. TemplateNormalizer.prototype.normalizeTemplate = function (directiveType, template) {
  27020. var _this = this;
  27021. if (lang_1.isPresent(template.template)) {
  27022. return async_1.PromiseWrapper.resolve(this.normalizeLoadedTemplate(directiveType, template, template.template, directiveType.moduleUrl));
  27023. }
  27024. else if (lang_1.isPresent(template.templateUrl)) {
  27025. var sourceAbsUrl = this._urlResolver.resolve(directiveType.moduleUrl, template.templateUrl);
  27026. return this._xhr.get(sourceAbsUrl)
  27027. .then(function (templateContent) { return _this.normalizeLoadedTemplate(directiveType, template, templateContent, sourceAbsUrl); });
  27028. }
  27029. else {
  27030. throw new exceptions_1.BaseException("No template specified for component " + directiveType.name);
  27031. }
  27032. };
  27033. TemplateNormalizer.prototype.normalizeLoadedTemplate = function (directiveType, templateMeta, template, templateAbsUrl) {
  27034. var _this = this;
  27035. var rootNodesAndErrors = this._htmlParser.parse(template, directiveType.name);
  27036. if (rootNodesAndErrors.errors.length > 0) {
  27037. var errorString = rootNodesAndErrors.errors.join('\n');
  27038. throw new exceptions_1.BaseException("Template parse errors:\n" + errorString);
  27039. }
  27040. var visitor = new TemplatePreparseVisitor();
  27041. html_ast_1.htmlVisitAll(visitor, rootNodesAndErrors.rootNodes);
  27042. var allStyles = templateMeta.styles.concat(visitor.styles);
  27043. var allStyleAbsUrls = visitor.styleUrls.filter(style_url_resolver_1.isStyleUrlResolvable)
  27044. .map(function (url) { return _this._urlResolver.resolve(templateAbsUrl, url); })
  27045. .concat(templateMeta.styleUrls.filter(style_url_resolver_1.isStyleUrlResolvable)
  27046. .map(function (url) { return _this._urlResolver.resolve(directiveType.moduleUrl, url); }));
  27047. var allResolvedStyles = allStyles.map(function (style) {
  27048. var styleWithImports = style_url_resolver_1.extractStyleUrls(_this._urlResolver, templateAbsUrl, style);
  27049. styleWithImports.styleUrls.forEach(function (styleUrl) { return allStyleAbsUrls.push(styleUrl); });
  27050. return styleWithImports.style;
  27051. });
  27052. var encapsulation = templateMeta.encapsulation;
  27053. if (encapsulation === view_1.ViewEncapsulation.Emulated && allResolvedStyles.length === 0 &&
  27054. allStyleAbsUrls.length === 0) {
  27055. encapsulation = view_1.ViewEncapsulation.None;
  27056. }
  27057. return new directive_metadata_1.CompileTemplateMetadata({
  27058. encapsulation: encapsulation,
  27059. template: template,
  27060. templateUrl: templateAbsUrl,
  27061. styles: allResolvedStyles,
  27062. styleUrls: allStyleAbsUrls,
  27063. ngContentSelectors: visitor.ngContentSelectors
  27064. });
  27065. };
  27066. TemplateNormalizer = __decorate([
  27067. di_1.Injectable(),
  27068. __metadata('design:paramtypes', [xhr_1.XHR, url_resolver_1.UrlResolver, html_parser_1.HtmlParser])
  27069. ], TemplateNormalizer);
  27070. return TemplateNormalizer;
  27071. })();
  27072. exports.TemplateNormalizer = TemplateNormalizer;
  27073. var TemplatePreparseVisitor = (function () {
  27074. function TemplatePreparseVisitor() {
  27075. this.ngContentSelectors = [];
  27076. this.styles = [];
  27077. this.styleUrls = [];
  27078. this.ngNonBindableStackCount = 0;
  27079. }
  27080. TemplatePreparseVisitor.prototype.visitElement = function (ast, context) {
  27081. var preparsedElement = template_preparser_1.preparseElement(ast);
  27082. switch (preparsedElement.type) {
  27083. case template_preparser_1.PreparsedElementType.NG_CONTENT:
  27084. if (this.ngNonBindableStackCount === 0) {
  27085. this.ngContentSelectors.push(preparsedElement.selectAttr);
  27086. }
  27087. break;
  27088. case template_preparser_1.PreparsedElementType.STYLE:
  27089. var textContent = '';
  27090. ast.children.forEach(function (child) {
  27091. if (child instanceof html_ast_1.HtmlTextAst) {
  27092. textContent += child.value;
  27093. }
  27094. });
  27095. this.styles.push(textContent);
  27096. break;
  27097. case template_preparser_1.PreparsedElementType.STYLESHEET:
  27098. this.styleUrls.push(preparsedElement.hrefAttr);
  27099. break;
  27100. }
  27101. if (preparsedElement.nonBindable) {
  27102. this.ngNonBindableStackCount++;
  27103. }
  27104. html_ast_1.htmlVisitAll(this, ast.children);
  27105. if (preparsedElement.nonBindable) {
  27106. this.ngNonBindableStackCount--;
  27107. }
  27108. return null;
  27109. };
  27110. TemplatePreparseVisitor.prototype.visitAttr = function (ast, context) { return null; };
  27111. TemplatePreparseVisitor.prototype.visitText = function (ast, context) { return null; };
  27112. return TemplatePreparseVisitor;
  27113. })();
  27114. /***/ },
  27115. /* 176 */
  27116. /***/ function(module, exports, __webpack_require__) {
  27117. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  27118. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  27119. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  27120. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  27121. return c > 3 && r && Object.defineProperty(target, key, r), r;
  27122. };
  27123. var __metadata = (this && this.__metadata) || function (k, v) {
  27124. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  27125. };
  27126. var __param = (this && this.__param) || function (paramIndex, decorator) {
  27127. return function (target, key) { decorator(target, key, paramIndex); }
  27128. };
  27129. var di_1 = __webpack_require__(6);
  27130. var lang_1 = __webpack_require__(5);
  27131. var exceptions_1 = __webpack_require__(14);
  27132. var cpl = __webpack_require__(153);
  27133. var md = __webpack_require__(23);
  27134. var directive_resolver_1 = __webpack_require__(92);
  27135. var view_resolver_1 = __webpack_require__(93);
  27136. var directive_lifecycle_reflector_1 = __webpack_require__(88);
  27137. var interfaces_1 = __webpack_require__(89);
  27138. var reflection_1 = __webpack_require__(16);
  27139. var di_2 = __webpack_require__(6);
  27140. var platform_directives_and_pipes_1 = __webpack_require__(95);
  27141. var util_1 = __webpack_require__(155);
  27142. var url_resolver_1 = __webpack_require__(148);
  27143. var RuntimeMetadataResolver = (function () {
  27144. function RuntimeMetadataResolver(_directiveResolver, _viewResolver, _platformDirectives) {
  27145. this._directiveResolver = _directiveResolver;
  27146. this._viewResolver = _viewResolver;
  27147. this._platformDirectives = _platformDirectives;
  27148. this._cache = new Map();
  27149. }
  27150. RuntimeMetadataResolver.prototype.getMetadata = function (directiveType) {
  27151. var meta = this._cache.get(directiveType);
  27152. if (lang_1.isBlank(meta)) {
  27153. var dirMeta = this._directiveResolver.resolve(directiveType);
  27154. var moduleUrl = null;
  27155. var templateMeta = null;
  27156. var changeDetectionStrategy = null;
  27157. if (dirMeta instanceof md.ComponentMetadata) {
  27158. var cmpMeta = dirMeta;
  27159. moduleUrl = calcModuleUrl(directiveType, cmpMeta);
  27160. var viewMeta = this._viewResolver.resolve(directiveType);
  27161. templateMeta = new cpl.CompileTemplateMetadata({
  27162. encapsulation: viewMeta.encapsulation,
  27163. template: viewMeta.template,
  27164. templateUrl: viewMeta.templateUrl,
  27165. styles: viewMeta.styles,
  27166. styleUrls: viewMeta.styleUrls
  27167. });
  27168. changeDetectionStrategy = cmpMeta.changeDetection;
  27169. }
  27170. meta = cpl.CompileDirectiveMetadata.create({
  27171. selector: dirMeta.selector,
  27172. exportAs: dirMeta.exportAs,
  27173. isComponent: lang_1.isPresent(templateMeta),
  27174. dynamicLoadable: true,
  27175. type: new cpl.CompileTypeMetadata({ name: lang_1.stringify(directiveType), moduleUrl: moduleUrl, runtime: directiveType }),
  27176. template: templateMeta,
  27177. changeDetection: changeDetectionStrategy,
  27178. inputs: dirMeta.inputs,
  27179. outputs: dirMeta.outputs,
  27180. host: dirMeta.host,
  27181. lifecycleHooks: interfaces_1.LIFECYCLE_HOOKS_VALUES.filter(function (hook) { return directive_lifecycle_reflector_1.hasLifecycleHook(hook, directiveType); })
  27182. });
  27183. this._cache.set(directiveType, meta);
  27184. }
  27185. return meta;
  27186. };
  27187. RuntimeMetadataResolver.prototype.getViewDirectivesMetadata = function (component) {
  27188. var _this = this;
  27189. var view = this._viewResolver.resolve(component);
  27190. var directives = flattenDirectives(view, this._platformDirectives);
  27191. for (var i = 0; i < directives.length; i++) {
  27192. if (!isValidDirective(directives[i])) {
  27193. throw new exceptions_1.BaseException("Unexpected directive value '" + lang_1.stringify(directives[i]) + "' on the View of component '" + lang_1.stringify(component) + "'");
  27194. }
  27195. }
  27196. return directives.map(function (type) { return _this.getMetadata(type); });
  27197. };
  27198. RuntimeMetadataResolver = __decorate([
  27199. di_2.Injectable(),
  27200. __param(2, di_2.Optional()),
  27201. __param(2, di_2.Inject(platform_directives_and_pipes_1.PLATFORM_DIRECTIVES)),
  27202. __metadata('design:paramtypes', [directive_resolver_1.DirectiveResolver, view_resolver_1.ViewResolver, Array])
  27203. ], RuntimeMetadataResolver);
  27204. return RuntimeMetadataResolver;
  27205. })();
  27206. exports.RuntimeMetadataResolver = RuntimeMetadataResolver;
  27207. function flattenDirectives(view, platformDirectives) {
  27208. var directives = [];
  27209. if (lang_1.isPresent(platformDirectives)) {
  27210. flattenArray(platformDirectives, directives);
  27211. }
  27212. if (lang_1.isPresent(view.directives)) {
  27213. flattenArray(view.directives, directives);
  27214. }
  27215. return directives;
  27216. }
  27217. function flattenArray(tree, out) {
  27218. for (var i = 0; i < tree.length; i++) {
  27219. var item = di_1.resolveForwardRef(tree[i]);
  27220. if (lang_1.isArray(item)) {
  27221. flattenArray(item, out);
  27222. }
  27223. else {
  27224. out.push(item);
  27225. }
  27226. }
  27227. }
  27228. function isValidDirective(value) {
  27229. return lang_1.isPresent(value) && (value instanceof lang_1.Type);
  27230. }
  27231. function calcModuleUrl(type, cmpMetadata) {
  27232. var moduleId = cmpMetadata.moduleId;
  27233. if (lang_1.isPresent(moduleId)) {
  27234. var scheme = url_resolver_1.getUrlScheme(moduleId);
  27235. return lang_1.isPresent(scheme) && scheme.length > 0 ? moduleId :
  27236. "package:" + moduleId + util_1.MODULE_SUFFIX;
  27237. }
  27238. else {
  27239. return reflection_1.reflector.importUri(type);
  27240. }
  27241. }
  27242. /***/ },
  27243. /* 177 */
  27244. /***/ function(module, exports, __webpack_require__) {
  27245. var __extends = (this && this.__extends) || function (d, b) {
  27246. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  27247. function __() { this.constructor = d; }
  27248. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  27249. };
  27250. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  27251. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  27252. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  27253. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  27254. return c > 3 && r && Object.defineProperty(target, key, r), r;
  27255. };
  27256. var __metadata = (this && this.__metadata) || function (k, v) {
  27257. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  27258. };
  27259. var di_1 = __webpack_require__(6);
  27260. var lang_1 = __webpack_require__(5);
  27261. var collection_1 = __webpack_require__(12);
  27262. var dom_adapter_1 = __webpack_require__(178);
  27263. var html_tags_1 = __webpack_require__(172);
  27264. var element_schema_registry_1 = __webpack_require__(173);
  27265. var NAMESPACE_URIS = lang_1.CONST_EXPR({ 'xlink': 'http://www.w3.org/1999/xlink', 'svg': 'http://www.w3.org/2000/svg' });
  27266. var DomElementSchemaRegistry = (function (_super) {
  27267. __extends(DomElementSchemaRegistry, _super);
  27268. function DomElementSchemaRegistry() {
  27269. _super.apply(this, arguments);
  27270. this._protoElements = new Map();
  27271. }
  27272. DomElementSchemaRegistry.prototype._getProtoElement = function (tagName) {
  27273. var element = this._protoElements.get(tagName);
  27274. if (lang_1.isBlank(element)) {
  27275. var nsAndName = html_tags_1.splitNsName(tagName);
  27276. element = lang_1.isPresent(nsAndName[0]) ?
  27277. dom_adapter_1.DOM.createElementNS(NAMESPACE_URIS[nsAndName[0]], nsAndName[1]) :
  27278. dom_adapter_1.DOM.createElement(nsAndName[1]);
  27279. this._protoElements.set(tagName, element);
  27280. }
  27281. return element;
  27282. };
  27283. DomElementSchemaRegistry.prototype.hasProperty = function (tagName, propName) {
  27284. if (tagName.indexOf('-') !== -1) {
  27285. // can't tell now as we don't know which properties a custom element will get
  27286. // once it is instantiated
  27287. return true;
  27288. }
  27289. else {
  27290. var elm = this._getProtoElement(tagName);
  27291. return dom_adapter_1.DOM.hasProperty(elm, propName);
  27292. }
  27293. };
  27294. DomElementSchemaRegistry.prototype.getMappedPropName = function (propName) {
  27295. var mappedPropName = collection_1.StringMapWrapper.get(dom_adapter_1.DOM.attrToPropMap, propName);
  27296. return lang_1.isPresent(mappedPropName) ? mappedPropName : propName;
  27297. };
  27298. DomElementSchemaRegistry = __decorate([
  27299. di_1.Injectable(),
  27300. __metadata('design:paramtypes', [])
  27301. ], DomElementSchemaRegistry);
  27302. return DomElementSchemaRegistry;
  27303. })(element_schema_registry_1.ElementSchemaRegistry);
  27304. exports.DomElementSchemaRegistry = DomElementSchemaRegistry;
  27305. /***/ },
  27306. /* 178 */
  27307. /***/ function(module, exports, __webpack_require__) {
  27308. var lang_1 = __webpack_require__(5);
  27309. exports.DOM = null;
  27310. function setRootDomAdapter(adapter) {
  27311. if (lang_1.isBlank(exports.DOM)) {
  27312. exports.DOM = adapter;
  27313. }
  27314. }
  27315. exports.setRootDomAdapter = setRootDomAdapter;
  27316. /* tslint:disable:requireParameterType */
  27317. /**
  27318. * Provides DOM operations in an environment-agnostic way.
  27319. */
  27320. var DomAdapter = (function () {
  27321. function DomAdapter() {
  27322. }
  27323. return DomAdapter;
  27324. })();
  27325. exports.DomAdapter = DomAdapter;
  27326. /***/ },
  27327. /* 179 */
  27328. /***/ function(module, exports, __webpack_require__) {
  27329. var angular_entrypoint_1 = __webpack_require__(180);
  27330. exports.AngularEntrypoint = angular_entrypoint_1.AngularEntrypoint;
  27331. var browser_common_1 = __webpack_require__(181);
  27332. exports.BROWSER_PROVIDERS = browser_common_1.BROWSER_PROVIDERS;
  27333. exports.ELEMENT_PROBE_BINDINGS = browser_common_1.ELEMENT_PROBE_BINDINGS;
  27334. exports.ELEMENT_PROBE_PROVIDERS = browser_common_1.ELEMENT_PROBE_PROVIDERS;
  27335. exports.inspectNativeElement = browser_common_1.inspectNativeElement;
  27336. exports.BrowserDomAdapter = browser_common_1.BrowserDomAdapter;
  27337. exports.By = browser_common_1.By;
  27338. exports.Title = browser_common_1.Title;
  27339. exports.DOCUMENT = browser_common_1.DOCUMENT;
  27340. exports.enableDebugTools = browser_common_1.enableDebugTools;
  27341. exports.disableDebugTools = browser_common_1.disableDebugTools;
  27342. var lang_1 = __webpack_require__(5);
  27343. var browser_common_2 = __webpack_require__(181);
  27344. var compiler_1 = __webpack_require__(147);
  27345. var core_1 = __webpack_require__(2);
  27346. var reflection_capabilities_1 = __webpack_require__(18);
  27347. var xhr_impl_1 = __webpack_require__(199);
  27348. var compiler_2 = __webpack_require__(147);
  27349. var di_1 = __webpack_require__(6);
  27350. /**
  27351. * An array of providers that should be passed into `application()` when bootstrapping a component.
  27352. */
  27353. exports.BROWSER_APP_PROVIDERS = lang_1.CONST_EXPR([
  27354. browser_common_2.BROWSER_APP_COMMON_PROVIDERS,
  27355. compiler_1.COMPILER_PROVIDERS,
  27356. new di_1.Provider(compiler_2.XHR, { useClass: xhr_impl_1.XHRImpl }),
  27357. ]);
  27358. /**
  27359. * Bootstrapping for Angular applications.
  27360. *
  27361. * You instantiate an Angular application by explicitly specifying a component to use
  27362. * as the root component for your application via the `bootstrap()` method.
  27363. *
  27364. * ## Simple Example
  27365. *
  27366. * Assuming this `index.html`:
  27367. *
  27368. * ```html
  27369. * <html>
  27370. * <!-- load Angular script tags here. -->
  27371. * <body>
  27372. * <my-app>loading...</my-app>
  27373. * </body>
  27374. * </html>
  27375. * ```
  27376. *
  27377. * An application is bootstrapped inside an existing browser DOM, typically `index.html`.
  27378. * Unlike Angular 1, Angular 2 does not compile/process providers in `index.html`. This is
  27379. * mainly for security reasons, as well as architectural changes in Angular 2. This means
  27380. * that `index.html` can safely be processed using server-side technologies such as
  27381. * providers. Bindings can thus use double-curly `{{ syntax }}` without collision from
  27382. * Angular 2 component double-curly `{{ syntax }}`.
  27383. *
  27384. * We can use this script code:
  27385. *
  27386. * {@example core/ts/bootstrap/bootstrap.ts region='bootstrap'}
  27387. *
  27388. * When the app developer invokes `bootstrap()` with the root component `MyApp` as its
  27389. * argument, Angular performs the following tasks:
  27390. *
  27391. * 1. It uses the component's `selector` property to locate the DOM element which needs
  27392. * to be upgraded into the angular component.
  27393. * 2. It creates a new child injector (from the platform injector). Optionally, you can
  27394. * also override the injector configuration for an app by invoking `bootstrap` with the
  27395. * `componentInjectableBindings` argument.
  27396. * 3. It creates a new `Zone` and connects it to the angular application's change detection
  27397. * domain instance.
  27398. * 4. It creates an emulated or shadow DOM on the selected component's host element and loads the
  27399. * template into it.
  27400. * 5. It instantiates the specified component.
  27401. * 6. Finally, Angular performs change detection to apply the initial data providers for the
  27402. * application.
  27403. *
  27404. *
  27405. * ## Bootstrapping Multiple Applications
  27406. *
  27407. * When working within a browser window, there are many singleton resources: cookies, title,
  27408. * location, and others. Angular services that represent these resources must likewise be
  27409. * shared across all Angular applications that occupy the same browser window. For this
  27410. * reason, Angular creates exactly one global platform object which stores all shared
  27411. * services, and each angular application injector has the platform injector as its parent.
  27412. *
  27413. * Each application has its own private injector as well. When there are multiple
  27414. * applications on a page, Angular treats each application injector's services as private
  27415. * to that application.
  27416. *
  27417. * ## API
  27418. *
  27419. * - `appComponentType`: The root component which should act as the application. This is
  27420. * a reference to a `Type` which is annotated with `@Component(...)`.
  27421. * - `customProviders`: An additional set of providers that can be added to the
  27422. * app injector to override default injection behavior.
  27423. *
  27424. * Returns a `Promise` of {@link ComponentRef}.
  27425. */
  27426. function bootstrap(appComponentType, customProviders) {
  27427. core_1.reflector.reflectionCapabilities = new reflection_capabilities_1.ReflectionCapabilities();
  27428. var appProviders = lang_1.isPresent(customProviders) ? [exports.BROWSER_APP_PROVIDERS, customProviders] : exports.BROWSER_APP_PROVIDERS;
  27429. return core_1.platform(browser_common_2.BROWSER_PROVIDERS).application(appProviders).bootstrap(appComponentType);
  27430. }
  27431. exports.bootstrap = bootstrap;
  27432. /***/ },
  27433. /* 180 */
  27434. /***/ function(module, exports, __webpack_require__) {
  27435. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  27436. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  27437. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  27438. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  27439. return c > 3 && r && Object.defineProperty(target, key, r), r;
  27440. };
  27441. var __metadata = (this && this.__metadata) || function (k, v) {
  27442. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  27443. };
  27444. var lang_1 = __webpack_require__(5);
  27445. /**
  27446. * Marks a function or method as an Angular 2 entrypoint. Only necessary in Dart code.
  27447. *
  27448. * The optional `name` parameter will be reflected in logs when the entry point is processed.
  27449. *
  27450. * See [the wiki][] for detailed documentation.
  27451. * [the wiki]: https://github.com/angular/angular/wiki/Angular-2-Dart-Transformer#entry_points
  27452. *
  27453. * ## Example
  27454. *
  27455. * ```
  27456. * @AngularEntrypoint("name-for-debug")
  27457. * void main() {
  27458. * bootstrap(MyComponent);
  27459. * }
  27460. * ```
  27461. */
  27462. var AngularEntrypoint = (function () {
  27463. function AngularEntrypoint(name) {
  27464. this.name = name;
  27465. }
  27466. AngularEntrypoint = __decorate([
  27467. lang_1.CONST(),
  27468. __metadata('design:paramtypes', [String])
  27469. ], AngularEntrypoint);
  27470. return AngularEntrypoint;
  27471. })();
  27472. exports.AngularEntrypoint = AngularEntrypoint;
  27473. /***/ },
  27474. /* 181 */
  27475. /***/ function(module, exports, __webpack_require__) {
  27476. var lang_1 = __webpack_require__(5);
  27477. var di_1 = __webpack_require__(6);
  27478. var core_1 = __webpack_require__(2);
  27479. var common_1 = __webpack_require__(104);
  27480. var testability_1 = __webpack_require__(68);
  27481. var dom_adapter_1 = __webpack_require__(178);
  27482. var dom_events_1 = __webpack_require__(182);
  27483. var key_events_1 = __webpack_require__(184);
  27484. var hammer_gestures_1 = __webpack_require__(185);
  27485. var dom_tokens_1 = __webpack_require__(187);
  27486. var dom_renderer_1 = __webpack_require__(188);
  27487. var shared_styles_host_1 = __webpack_require__(196);
  27488. var shared_styles_host_2 = __webpack_require__(196);
  27489. var browser_details_1 = __webpack_require__(195);
  27490. var animation_builder_1 = __webpack_require__(189);
  27491. var browser_adapter_1 = __webpack_require__(197);
  27492. var testability_2 = __webpack_require__(200);
  27493. var wtf_init_1 = __webpack_require__(201);
  27494. var event_manager_1 = __webpack_require__(183);
  27495. var dom_tokens_2 = __webpack_require__(187);
  27496. exports.DOCUMENT = dom_tokens_2.DOCUMENT;
  27497. var title_1 = __webpack_require__(202);
  27498. exports.Title = title_1.Title;
  27499. var common_dom_1 = __webpack_require__(203);
  27500. exports.DebugElementViewListener = common_dom_1.DebugElementViewListener;
  27501. exports.ELEMENT_PROBE_PROVIDERS = common_dom_1.ELEMENT_PROBE_PROVIDERS;
  27502. exports.ELEMENT_PROBE_BINDINGS = common_dom_1.ELEMENT_PROBE_BINDINGS;
  27503. exports.inspectNativeElement = common_dom_1.inspectNativeElement;
  27504. exports.By = common_dom_1.By;
  27505. var browser_adapter_2 = __webpack_require__(197);
  27506. exports.BrowserDomAdapter = browser_adapter_2.BrowserDomAdapter;
  27507. var tools_1 = __webpack_require__(206);
  27508. exports.enableDebugTools = tools_1.enableDebugTools;
  27509. exports.disableDebugTools = tools_1.disableDebugTools;
  27510. /**
  27511. * A set of providers to initialize the Angular platform in a web browser.
  27512. *
  27513. * Used automatically by `bootstrap`, or can be passed to {@link platform}.
  27514. */
  27515. exports.BROWSER_PROVIDERS = lang_1.CONST_EXPR([
  27516. core_1.PLATFORM_COMMON_PROVIDERS,
  27517. new di_1.Provider(core_1.PLATFORM_INITIALIZER, { useValue: initDomAdapter, multi: true }),
  27518. ]);
  27519. function _exceptionHandler() {
  27520. // !IS_DART is required because we must rethrow exceptions in JS,
  27521. // but must not rethrow exceptions in Dart
  27522. return new core_1.ExceptionHandler(dom_adapter_1.DOM, !lang_1.IS_DART);
  27523. }
  27524. function _document() {
  27525. return dom_adapter_1.DOM.defaultDoc();
  27526. }
  27527. /**
  27528. * A set of providers to initialize an Angular application in a web browser.
  27529. *
  27530. * Used automatically by `bootstrap`, or can be passed to {@link PlatformRef.application}.
  27531. */
  27532. exports.BROWSER_APP_COMMON_PROVIDERS = lang_1.CONST_EXPR([
  27533. core_1.APPLICATION_COMMON_PROVIDERS,
  27534. common_1.FORM_PROVIDERS,
  27535. new di_1.Provider(core_1.PLATFORM_PIPES, { useValue: common_1.COMMON_PIPES, multi: true }),
  27536. new di_1.Provider(core_1.PLATFORM_DIRECTIVES, { useValue: common_1.COMMON_DIRECTIVES, multi: true }),
  27537. new di_1.Provider(core_1.ExceptionHandler, { useFactory: _exceptionHandler, deps: [] }),
  27538. new di_1.Provider(dom_tokens_1.DOCUMENT, { useFactory: _document, deps: [] }),
  27539. new di_1.Provider(event_manager_1.EVENT_MANAGER_PLUGINS, { useClass: dom_events_1.DomEventsPlugin, multi: true }),
  27540. new di_1.Provider(event_manager_1.EVENT_MANAGER_PLUGINS, { useClass: key_events_1.KeyEventsPlugin, multi: true }),
  27541. new di_1.Provider(event_manager_1.EVENT_MANAGER_PLUGINS, { useClass: hammer_gestures_1.HammerGesturesPlugin, multi: true }),
  27542. new di_1.Provider(dom_renderer_1.DomRenderer, { useClass: dom_renderer_1.DomRenderer_ }),
  27543. new di_1.Provider(core_1.Renderer, { useExisting: dom_renderer_1.DomRenderer }),
  27544. new di_1.Provider(shared_styles_host_2.SharedStylesHost, { useExisting: shared_styles_host_1.DomSharedStylesHost }),
  27545. shared_styles_host_1.DomSharedStylesHost,
  27546. testability_1.Testability,
  27547. browser_details_1.BrowserDetails,
  27548. animation_builder_1.AnimationBuilder,
  27549. event_manager_1.EventManager
  27550. ]);
  27551. function initDomAdapter() {
  27552. browser_adapter_1.BrowserDomAdapter.makeCurrent();
  27553. wtf_init_1.wtfInit();
  27554. testability_2.BrowserGetTestability.init();
  27555. }
  27556. exports.initDomAdapter = initDomAdapter;
  27557. /***/ },
  27558. /* 182 */
  27559. /***/ function(module, exports, __webpack_require__) {
  27560. var __extends = (this && this.__extends) || function (d, b) {
  27561. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  27562. function __() { this.constructor = d; }
  27563. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  27564. };
  27565. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  27566. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  27567. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  27568. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  27569. return c > 3 && r && Object.defineProperty(target, key, r), r;
  27570. };
  27571. var __metadata = (this && this.__metadata) || function (k, v) {
  27572. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  27573. };
  27574. var dom_adapter_1 = __webpack_require__(178);
  27575. var core_1 = __webpack_require__(2);
  27576. var event_manager_1 = __webpack_require__(183);
  27577. var DomEventsPlugin = (function (_super) {
  27578. __extends(DomEventsPlugin, _super);
  27579. function DomEventsPlugin() {
  27580. _super.apply(this, arguments);
  27581. }
  27582. // This plugin should come last in the list of plugins, because it accepts all
  27583. // events.
  27584. DomEventsPlugin.prototype.supports = function (eventName) { return true; };
  27585. DomEventsPlugin.prototype.addEventListener = function (element, eventName, handler) {
  27586. var zone = this.manager.getZone();
  27587. var outsideHandler = function (event) { return zone.run(function () { return handler(event); }); };
  27588. this.manager.getZone().runOutsideAngular(function () { dom_adapter_1.DOM.on(element, eventName, outsideHandler); });
  27589. };
  27590. DomEventsPlugin.prototype.addGlobalEventListener = function (target, eventName, handler) {
  27591. var element = dom_adapter_1.DOM.getGlobalEventTarget(target);
  27592. var zone = this.manager.getZone();
  27593. var outsideHandler = function (event) { return zone.run(function () { return handler(event); }); };
  27594. return this.manager.getZone().runOutsideAngular(function () { return dom_adapter_1.DOM.onAndCancel(element, eventName, outsideHandler); });
  27595. };
  27596. DomEventsPlugin = __decorate([
  27597. core_1.Injectable(),
  27598. __metadata('design:paramtypes', [])
  27599. ], DomEventsPlugin);
  27600. return DomEventsPlugin;
  27601. })(event_manager_1.EventManagerPlugin);
  27602. exports.DomEventsPlugin = DomEventsPlugin;
  27603. /***/ },
  27604. /* 183 */
  27605. /***/ function(module, exports, __webpack_require__) {
  27606. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  27607. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  27608. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  27609. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  27610. return c > 3 && r && Object.defineProperty(target, key, r), r;
  27611. };
  27612. var __metadata = (this && this.__metadata) || function (k, v) {
  27613. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  27614. };
  27615. var __param = (this && this.__param) || function (paramIndex, decorator) {
  27616. return function (target, key) { decorator(target, key, paramIndex); }
  27617. };
  27618. var lang_1 = __webpack_require__(5);
  27619. var exceptions_1 = __webpack_require__(14);
  27620. var di_1 = __webpack_require__(6);
  27621. var ng_zone_1 = __webpack_require__(66);
  27622. var collection_1 = __webpack_require__(12);
  27623. exports.EVENT_MANAGER_PLUGINS = lang_1.CONST_EXPR(new di_1.OpaqueToken("EventManagerPlugins"));
  27624. var EventManager = (function () {
  27625. function EventManager(plugins, _zone) {
  27626. var _this = this;
  27627. this._zone = _zone;
  27628. plugins.forEach(function (p) { return p.manager = _this; });
  27629. this._plugins = collection_1.ListWrapper.reversed(plugins);
  27630. }
  27631. EventManager.prototype.addEventListener = function (element, eventName, handler) {
  27632. var plugin = this._findPluginFor(eventName);
  27633. plugin.addEventListener(element, eventName, handler);
  27634. };
  27635. EventManager.prototype.addGlobalEventListener = function (target, eventName, handler) {
  27636. var plugin = this._findPluginFor(eventName);
  27637. return plugin.addGlobalEventListener(target, eventName, handler);
  27638. };
  27639. EventManager.prototype.getZone = function () { return this._zone; };
  27640. /** @internal */
  27641. EventManager.prototype._findPluginFor = function (eventName) {
  27642. var plugins = this._plugins;
  27643. for (var i = 0; i < plugins.length; i++) {
  27644. var plugin = plugins[i];
  27645. if (plugin.supports(eventName)) {
  27646. return plugin;
  27647. }
  27648. }
  27649. throw new exceptions_1.BaseException("No event manager plugin found for event " + eventName);
  27650. };
  27651. EventManager = __decorate([
  27652. di_1.Injectable(),
  27653. __param(0, di_1.Inject(exports.EVENT_MANAGER_PLUGINS)),
  27654. __metadata('design:paramtypes', [Array, ng_zone_1.NgZone])
  27655. ], EventManager);
  27656. return EventManager;
  27657. })();
  27658. exports.EventManager = EventManager;
  27659. var EventManagerPlugin = (function () {
  27660. function EventManagerPlugin() {
  27661. }
  27662. // That is equivalent to having supporting $event.target
  27663. EventManagerPlugin.prototype.supports = function (eventName) { return false; };
  27664. EventManagerPlugin.prototype.addEventListener = function (element, eventName, handler) {
  27665. throw "not implemented";
  27666. };
  27667. EventManagerPlugin.prototype.addGlobalEventListener = function (element, eventName, handler) {
  27668. throw "not implemented";
  27669. };
  27670. return EventManagerPlugin;
  27671. })();
  27672. exports.EventManagerPlugin = EventManagerPlugin;
  27673. /***/ },
  27674. /* 184 */
  27675. /***/ function(module, exports, __webpack_require__) {
  27676. var __extends = (this && this.__extends) || function (d, b) {
  27677. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  27678. function __() { this.constructor = d; }
  27679. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  27680. };
  27681. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  27682. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  27683. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  27684. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  27685. return c > 3 && r && Object.defineProperty(target, key, r), r;
  27686. };
  27687. var __metadata = (this && this.__metadata) || function (k, v) {
  27688. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  27689. };
  27690. var dom_adapter_1 = __webpack_require__(178);
  27691. var lang_1 = __webpack_require__(5);
  27692. var collection_1 = __webpack_require__(12);
  27693. var event_manager_1 = __webpack_require__(183);
  27694. var di_1 = __webpack_require__(6);
  27695. var modifierKeys = ['alt', 'control', 'meta', 'shift'];
  27696. var modifierKeyGetters = {
  27697. 'alt': function (event) { return event.altKey; },
  27698. 'control': function (event) { return event.ctrlKey; },
  27699. 'meta': function (event) { return event.metaKey; },
  27700. 'shift': function (event) { return event.shiftKey; }
  27701. };
  27702. var KeyEventsPlugin = (function (_super) {
  27703. __extends(KeyEventsPlugin, _super);
  27704. function KeyEventsPlugin() {
  27705. _super.call(this);
  27706. }
  27707. KeyEventsPlugin.prototype.supports = function (eventName) {
  27708. return lang_1.isPresent(KeyEventsPlugin.parseEventName(eventName));
  27709. };
  27710. KeyEventsPlugin.prototype.addEventListener = function (element, eventName, handler) {
  27711. var parsedEvent = KeyEventsPlugin.parseEventName(eventName);
  27712. var outsideHandler = KeyEventsPlugin.eventCallback(element, collection_1.StringMapWrapper.get(parsedEvent, 'fullKey'), handler, this.manager.getZone());
  27713. this.manager.getZone().runOutsideAngular(function () {
  27714. dom_adapter_1.DOM.on(element, collection_1.StringMapWrapper.get(parsedEvent, 'domEventName'), outsideHandler);
  27715. });
  27716. };
  27717. KeyEventsPlugin.parseEventName = function (eventName) {
  27718. var parts = eventName.toLowerCase().split('.');
  27719. var domEventName = parts.shift();
  27720. if ((parts.length === 0) ||
  27721. !(lang_1.StringWrapper.equals(domEventName, 'keydown') ||
  27722. lang_1.StringWrapper.equals(domEventName, 'keyup'))) {
  27723. return null;
  27724. }
  27725. var key = KeyEventsPlugin._normalizeKey(parts.pop());
  27726. var fullKey = '';
  27727. modifierKeys.forEach(function (modifierName) {
  27728. if (collection_1.ListWrapper.contains(parts, modifierName)) {
  27729. collection_1.ListWrapper.remove(parts, modifierName);
  27730. fullKey += modifierName + '.';
  27731. }
  27732. });
  27733. fullKey += key;
  27734. if (parts.length != 0 || key.length === 0) {
  27735. // returning null instead of throwing to let another plugin process the event
  27736. return null;
  27737. }
  27738. var result = collection_1.StringMapWrapper.create();
  27739. collection_1.StringMapWrapper.set(result, 'domEventName', domEventName);
  27740. collection_1.StringMapWrapper.set(result, 'fullKey', fullKey);
  27741. return result;
  27742. };
  27743. KeyEventsPlugin.getEventFullKey = function (event) {
  27744. var fullKey = '';
  27745. var key = dom_adapter_1.DOM.getEventKey(event);
  27746. key = key.toLowerCase();
  27747. if (lang_1.StringWrapper.equals(key, ' ')) {
  27748. key = 'space'; // for readability
  27749. }
  27750. else if (lang_1.StringWrapper.equals(key, '.')) {
  27751. key = 'dot'; // because '.' is used as a separator in event names
  27752. }
  27753. modifierKeys.forEach(function (modifierName) {
  27754. if (modifierName != key) {
  27755. var modifierGetter = collection_1.StringMapWrapper.get(modifierKeyGetters, modifierName);
  27756. if (modifierGetter(event)) {
  27757. fullKey += modifierName + '.';
  27758. }
  27759. }
  27760. });
  27761. fullKey += key;
  27762. return fullKey;
  27763. };
  27764. KeyEventsPlugin.eventCallback = function (element, fullKey, handler, zone) {
  27765. return function (event) {
  27766. if (lang_1.StringWrapper.equals(KeyEventsPlugin.getEventFullKey(event), fullKey)) {
  27767. zone.run(function () { return handler(event); });
  27768. }
  27769. };
  27770. };
  27771. /** @internal */
  27772. KeyEventsPlugin._normalizeKey = function (keyName) {
  27773. // TODO: switch to a StringMap if the mapping grows too much
  27774. switch (keyName) {
  27775. case 'esc':
  27776. return 'escape';
  27777. default:
  27778. return keyName;
  27779. }
  27780. };
  27781. KeyEventsPlugin = __decorate([
  27782. di_1.Injectable(),
  27783. __metadata('design:paramtypes', [])
  27784. ], KeyEventsPlugin);
  27785. return KeyEventsPlugin;
  27786. })(event_manager_1.EventManagerPlugin);
  27787. exports.KeyEventsPlugin = KeyEventsPlugin;
  27788. /***/ },
  27789. /* 185 */
  27790. /***/ function(module, exports, __webpack_require__) {
  27791. var __extends = (this && this.__extends) || function (d, b) {
  27792. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  27793. function __() { this.constructor = d; }
  27794. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  27795. };
  27796. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  27797. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  27798. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  27799. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  27800. return c > 3 && r && Object.defineProperty(target, key, r), r;
  27801. };
  27802. var __metadata = (this && this.__metadata) || function (k, v) {
  27803. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  27804. };
  27805. var hammer_common_1 = __webpack_require__(186);
  27806. var lang_1 = __webpack_require__(5);
  27807. var exceptions_1 = __webpack_require__(14);
  27808. var di_1 = __webpack_require__(6);
  27809. var HammerGesturesPlugin = (function (_super) {
  27810. __extends(HammerGesturesPlugin, _super);
  27811. function HammerGesturesPlugin() {
  27812. _super.apply(this, arguments);
  27813. }
  27814. HammerGesturesPlugin.prototype.supports = function (eventName) {
  27815. if (!_super.prototype.supports.call(this, eventName))
  27816. return false;
  27817. if (!lang_1.isPresent(window['Hammer'])) {
  27818. throw new exceptions_1.BaseException("Hammer.js is not loaded, can not bind " + eventName + " event");
  27819. }
  27820. return true;
  27821. };
  27822. HammerGesturesPlugin.prototype.addEventListener = function (element, eventName, handler) {
  27823. var zone = this.manager.getZone();
  27824. eventName = eventName.toLowerCase();
  27825. zone.runOutsideAngular(function () {
  27826. // Creating the manager bind events, must be done outside of angular
  27827. var mc = new Hammer(element);
  27828. mc.get('pinch').set({ enable: true });
  27829. mc.get('rotate').set({ enable: true });
  27830. mc.on(eventName, function (eventObj) { zone.run(function () { handler(eventObj); }); });
  27831. });
  27832. };
  27833. HammerGesturesPlugin = __decorate([
  27834. di_1.Injectable(),
  27835. __metadata('design:paramtypes', [])
  27836. ], HammerGesturesPlugin);
  27837. return HammerGesturesPlugin;
  27838. })(hammer_common_1.HammerGesturesPluginCommon);
  27839. exports.HammerGesturesPlugin = HammerGesturesPlugin;
  27840. /***/ },
  27841. /* 186 */
  27842. /***/ function(module, exports, __webpack_require__) {
  27843. var __extends = (this && this.__extends) || function (d, b) {
  27844. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  27845. function __() { this.constructor = d; }
  27846. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  27847. };
  27848. var event_manager_1 = __webpack_require__(183);
  27849. var collection_1 = __webpack_require__(12);
  27850. var _eventNames = {
  27851. // pan
  27852. 'pan': true,
  27853. 'panstart': true,
  27854. 'panmove': true,
  27855. 'panend': true,
  27856. 'pancancel': true,
  27857. 'panleft': true,
  27858. 'panright': true,
  27859. 'panup': true,
  27860. 'pandown': true,
  27861. // pinch
  27862. 'pinch': true,
  27863. 'pinchstart': true,
  27864. 'pinchmove': true,
  27865. 'pinchend': true,
  27866. 'pinchcancel': true,
  27867. 'pinchin': true,
  27868. 'pinchout': true,
  27869. // press
  27870. 'press': true,
  27871. 'pressup': true,
  27872. // rotate
  27873. 'rotate': true,
  27874. 'rotatestart': true,
  27875. 'rotatemove': true,
  27876. 'rotateend': true,
  27877. 'rotatecancel': true,
  27878. // swipe
  27879. 'swipe': true,
  27880. 'swipeleft': true,
  27881. 'swiperight': true,
  27882. 'swipeup': true,
  27883. 'swipedown': true,
  27884. // tap
  27885. 'tap': true,
  27886. };
  27887. var HammerGesturesPluginCommon = (function (_super) {
  27888. __extends(HammerGesturesPluginCommon, _super);
  27889. function HammerGesturesPluginCommon() {
  27890. _super.call(this);
  27891. }
  27892. HammerGesturesPluginCommon.prototype.supports = function (eventName) {
  27893. eventName = eventName.toLowerCase();
  27894. return collection_1.StringMapWrapper.contains(_eventNames, eventName);
  27895. };
  27896. return HammerGesturesPluginCommon;
  27897. })(event_manager_1.EventManagerPlugin);
  27898. exports.HammerGesturesPluginCommon = HammerGesturesPluginCommon;
  27899. /***/ },
  27900. /* 187 */
  27901. /***/ function(module, exports, __webpack_require__) {
  27902. var di_1 = __webpack_require__(6);
  27903. var lang_1 = __webpack_require__(5);
  27904. /**
  27905. * A DI Token representing the main rendering context. In a browser this is the DOM Document.
  27906. *
  27907. * Note: Document might not be available in the Application Context when Application and Rendering
  27908. * Contexts are not the same (e.g. when running the application into a Web Worker).
  27909. */
  27910. exports.DOCUMENT = lang_1.CONST_EXPR(new di_1.OpaqueToken('DocumentToken'));
  27911. /***/ },
  27912. /* 188 */
  27913. /***/ function(module, exports, __webpack_require__) {
  27914. var __extends = (this && this.__extends) || function (d, b) {
  27915. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  27916. function __() { this.constructor = d; }
  27917. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  27918. };
  27919. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  27920. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  27921. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  27922. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  27923. return c > 3 && r && Object.defineProperty(target, key, r), r;
  27924. };
  27925. var __metadata = (this && this.__metadata) || function (k, v) {
  27926. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  27927. };
  27928. var __param = (this && this.__param) || function (paramIndex, decorator) {
  27929. return function (target, key) { decorator(target, key, paramIndex); }
  27930. };
  27931. var di_1 = __webpack_require__(6);
  27932. var animation_builder_1 = __webpack_require__(189);
  27933. var lang_1 = __webpack_require__(5);
  27934. var exceptions_1 = __webpack_require__(14);
  27935. var shared_styles_host_1 = __webpack_require__(196);
  27936. var profile_1 = __webpack_require__(45);
  27937. var core_1 = __webpack_require__(2);
  27938. var event_manager_1 = __webpack_require__(183);
  27939. var dom_tokens_1 = __webpack_require__(187);
  27940. var view_factory_1 = __webpack_require__(164);
  27941. var view_1 = __webpack_require__(165);
  27942. var metadata_1 = __webpack_require__(3);
  27943. var dom_adapter_1 = __webpack_require__(178);
  27944. var util_1 = __webpack_require__(194);
  27945. var NAMESPACE_URIS = lang_1.CONST_EXPR({ 'xlink': 'http://www.w3.org/1999/xlink', 'svg': 'http://www.w3.org/2000/svg' });
  27946. var TEMPLATE_COMMENT_TEXT = 'template bindings={}';
  27947. var TEMPLATE_BINDINGS_EXP = /^template bindings=(.*)$/g;
  27948. var DomRenderer = (function (_super) {
  27949. __extends(DomRenderer, _super);
  27950. function DomRenderer() {
  27951. _super.apply(this, arguments);
  27952. }
  27953. DomRenderer.prototype.getNativeElementSync = function (location) {
  27954. return resolveInternalDomView(location.renderView).boundElements[location.boundElementIndex];
  27955. };
  27956. DomRenderer.prototype.getRootNodes = function (fragment) { return resolveInternalDomFragment(fragment); };
  27957. DomRenderer.prototype.attachFragmentAfterFragment = function (previousFragmentRef, fragmentRef) {
  27958. var previousFragmentNodes = resolveInternalDomFragment(previousFragmentRef);
  27959. if (previousFragmentNodes.length > 0) {
  27960. var sibling = previousFragmentNodes[previousFragmentNodes.length - 1];
  27961. var nodes = resolveInternalDomFragment(fragmentRef);
  27962. moveNodesAfterSibling(sibling, nodes);
  27963. this.animateNodesEnter(nodes);
  27964. }
  27965. };
  27966. /**
  27967. * Iterates through all nodes being added to the DOM and animates them if necessary
  27968. * @param nodes
  27969. */
  27970. DomRenderer.prototype.animateNodesEnter = function (nodes) {
  27971. for (var i = 0; i < nodes.length; i++)
  27972. this.animateNodeEnter(nodes[i]);
  27973. };
  27974. DomRenderer.prototype.attachFragmentAfterElement = function (elementRef, fragmentRef) {
  27975. var parentView = resolveInternalDomView(elementRef.renderView);
  27976. var element = parentView.boundElements[elementRef.boundElementIndex];
  27977. var nodes = resolveInternalDomFragment(fragmentRef);
  27978. moveNodesAfterSibling(element, nodes);
  27979. this.animateNodesEnter(nodes);
  27980. };
  27981. DomRenderer.prototype.hydrateView = function (viewRef) { resolveInternalDomView(viewRef).hydrate(); };
  27982. DomRenderer.prototype.dehydrateView = function (viewRef) { resolveInternalDomView(viewRef).dehydrate(); };
  27983. DomRenderer.prototype.createTemplateAnchor = function (attrNameAndValues) {
  27984. return dom_adapter_1.DOM.createComment(TEMPLATE_COMMENT_TEXT);
  27985. };
  27986. DomRenderer.prototype.createText = function (value) { return dom_adapter_1.DOM.createTextNode(lang_1.isPresent(value) ? value : ''); };
  27987. DomRenderer.prototype.appendChild = function (parent, child) { dom_adapter_1.DOM.appendChild(parent, child); };
  27988. DomRenderer.prototype.setElementProperty = function (location, propertyName, propertyValue) {
  27989. var view = resolveInternalDomView(location.renderView);
  27990. dom_adapter_1.DOM.setProperty(view.boundElements[location.boundElementIndex], propertyName, propertyValue);
  27991. };
  27992. DomRenderer.prototype.setElementAttribute = function (location, attributeName, attributeValue) {
  27993. var view = resolveInternalDomView(location.renderView);
  27994. var element = view.boundElements[location.boundElementIndex];
  27995. if (lang_1.isPresent(attributeValue)) {
  27996. dom_adapter_1.DOM.setAttribute(element, attributeName, lang_1.stringify(attributeValue));
  27997. }
  27998. else {
  27999. dom_adapter_1.DOM.removeAttribute(element, attributeName);
  28000. }
  28001. };
  28002. /**
  28003. * Used only in debug mode to serialize property changes to comment nodes,
  28004. * such as <template> placeholders.
  28005. */
  28006. DomRenderer.prototype.setBindingDebugInfo = function (location, propertyName, propertyValue) {
  28007. var view = resolveInternalDomView(location.renderView);
  28008. var element = view.boundElements[location.boundElementIndex];
  28009. var dashCasedPropertyName = util_1.camelCaseToDashCase(propertyName);
  28010. if (dom_adapter_1.DOM.isCommentNode(element)) {
  28011. var existingBindings = lang_1.RegExpWrapper.firstMatch(TEMPLATE_BINDINGS_EXP, lang_1.StringWrapper.replaceAll(dom_adapter_1.DOM.getText(element), /\n/g, ''));
  28012. var parsedBindings = lang_1.Json.parse(existingBindings[1]);
  28013. parsedBindings[dashCasedPropertyName] = propertyValue;
  28014. dom_adapter_1.DOM.setText(element, lang_1.StringWrapper.replace(TEMPLATE_COMMENT_TEXT, '{}', lang_1.Json.stringify(parsedBindings)));
  28015. }
  28016. else {
  28017. this.setElementAttribute(location, propertyName, propertyValue);
  28018. }
  28019. };
  28020. DomRenderer.prototype.setElementClass = function (location, className, isAdd) {
  28021. var view = resolveInternalDomView(location.renderView);
  28022. var element = view.boundElements[location.boundElementIndex];
  28023. if (isAdd) {
  28024. dom_adapter_1.DOM.addClass(element, className);
  28025. }
  28026. else {
  28027. dom_adapter_1.DOM.removeClass(element, className);
  28028. }
  28029. };
  28030. DomRenderer.prototype.setElementStyle = function (location, styleName, styleValue) {
  28031. var view = resolveInternalDomView(location.renderView);
  28032. var element = view.boundElements[location.boundElementIndex];
  28033. if (lang_1.isPresent(styleValue)) {
  28034. dom_adapter_1.DOM.setStyle(element, styleName, lang_1.stringify(styleValue));
  28035. }
  28036. else {
  28037. dom_adapter_1.DOM.removeStyle(element, styleName);
  28038. }
  28039. };
  28040. DomRenderer.prototype.invokeElementMethod = function (location, methodName, args) {
  28041. var view = resolveInternalDomView(location.renderView);
  28042. var element = view.boundElements[location.boundElementIndex];
  28043. dom_adapter_1.DOM.invoke(element, methodName, args);
  28044. };
  28045. DomRenderer.prototype.setText = function (viewRef, textNodeIndex, text) {
  28046. var view = resolveInternalDomView(viewRef);
  28047. dom_adapter_1.DOM.setText(view.boundTextNodes[textNodeIndex], text);
  28048. };
  28049. DomRenderer.prototype.setEventDispatcher = function (viewRef, dispatcher) {
  28050. resolveInternalDomView(viewRef).setEventDispatcher(dispatcher);
  28051. };
  28052. return DomRenderer;
  28053. })(core_1.Renderer);
  28054. exports.DomRenderer = DomRenderer;
  28055. var DomRenderer_ = (function (_super) {
  28056. __extends(DomRenderer_, _super);
  28057. function DomRenderer_(_eventManager, _domSharedStylesHost, _animate, document) {
  28058. _super.call(this);
  28059. this._eventManager = _eventManager;
  28060. this._domSharedStylesHost = _domSharedStylesHost;
  28061. this._animate = _animate;
  28062. this._componentTpls = new Map();
  28063. /** @internal */
  28064. this._createRootHostViewScope = profile_1.wtfCreateScope('DomRenderer#createRootHostView()');
  28065. /** @internal */
  28066. this._createViewScope = profile_1.wtfCreateScope('DomRenderer#createView()');
  28067. /** @internal */
  28068. this._detachFragmentScope = profile_1.wtfCreateScope('DomRenderer#detachFragment()');
  28069. this._document = document;
  28070. }
  28071. DomRenderer_.prototype.registerComponentTemplate = function (template) {
  28072. this._componentTpls.set(template.id, template);
  28073. if (template.encapsulation !== metadata_1.ViewEncapsulation.Native) {
  28074. var encapsulatedStyles = view_factory_1.encapsulateStyles(template);
  28075. this._domSharedStylesHost.addStyles(encapsulatedStyles);
  28076. }
  28077. };
  28078. DomRenderer_.prototype.createProtoView = function (componentTemplateId, cmds) {
  28079. return new view_1.DefaultProtoViewRef(this._componentTpls.get(componentTemplateId), cmds);
  28080. };
  28081. DomRenderer_.prototype.resolveComponentTemplate = function (templateId) {
  28082. return this._componentTpls.get(templateId);
  28083. };
  28084. DomRenderer_.prototype.createRootHostView = function (hostProtoViewRef, fragmentCount, hostElementSelector) {
  28085. var s = this._createRootHostViewScope();
  28086. var element = dom_adapter_1.DOM.querySelector(this._document, hostElementSelector);
  28087. if (lang_1.isBlank(element)) {
  28088. profile_1.wtfLeave(s);
  28089. throw new exceptions_1.BaseException("The selector \"" + hostElementSelector + "\" did not match any elements");
  28090. }
  28091. return profile_1.wtfLeave(s, this._createView(hostProtoViewRef, element));
  28092. };
  28093. DomRenderer_.prototype.createView = function (protoViewRef, fragmentCount) {
  28094. var s = this._createViewScope();
  28095. return profile_1.wtfLeave(s, this._createView(protoViewRef, null));
  28096. };
  28097. DomRenderer_.prototype._createView = function (protoViewRef, inplaceElement) {
  28098. var dpvr = protoViewRef;
  28099. var view = view_factory_1.createRenderView(dpvr.template, dpvr.cmds, inplaceElement, this);
  28100. var sdRoots = view.nativeShadowRoots;
  28101. for (var i = 0; i < sdRoots.length; i++) {
  28102. this._domSharedStylesHost.addHost(sdRoots[i]);
  28103. }
  28104. return new core_1.RenderViewWithFragments(view, view.fragments);
  28105. };
  28106. DomRenderer_.prototype.destroyView = function (viewRef) {
  28107. var view = viewRef;
  28108. var sdRoots = view.nativeShadowRoots;
  28109. for (var i = 0; i < sdRoots.length; i++) {
  28110. this._domSharedStylesHost.removeHost(sdRoots[i]);
  28111. }
  28112. };
  28113. DomRenderer_.prototype.animateNodeEnter = function (node) {
  28114. if (dom_adapter_1.DOM.isElementNode(node) && dom_adapter_1.DOM.hasClass(node, 'ng-animate')) {
  28115. dom_adapter_1.DOM.addClass(node, 'ng-enter');
  28116. this._animate.css()
  28117. .addAnimationClass('ng-enter-active')
  28118. .start(node)
  28119. .onComplete(function () { dom_adapter_1.DOM.removeClass(node, 'ng-enter'); });
  28120. }
  28121. };
  28122. DomRenderer_.prototype.animateNodeLeave = function (node) {
  28123. if (dom_adapter_1.DOM.isElementNode(node) && dom_adapter_1.DOM.hasClass(node, 'ng-animate')) {
  28124. dom_adapter_1.DOM.addClass(node, 'ng-leave');
  28125. this._animate.css()
  28126. .addAnimationClass('ng-leave-active')
  28127. .start(node)
  28128. .onComplete(function () {
  28129. dom_adapter_1.DOM.removeClass(node, 'ng-leave');
  28130. dom_adapter_1.DOM.remove(node);
  28131. });
  28132. }
  28133. else {
  28134. dom_adapter_1.DOM.remove(node);
  28135. }
  28136. };
  28137. DomRenderer_.prototype.detachFragment = function (fragmentRef) {
  28138. var s = this._detachFragmentScope();
  28139. var fragmentNodes = resolveInternalDomFragment(fragmentRef);
  28140. for (var i = 0; i < fragmentNodes.length; i++) {
  28141. this.animateNodeLeave(fragmentNodes[i]);
  28142. }
  28143. profile_1.wtfLeave(s);
  28144. };
  28145. DomRenderer_.prototype.createElement = function (name, attrNameAndValues) {
  28146. var nsAndName = splitNamespace(name);
  28147. var el = lang_1.isPresent(nsAndName[0]) ?
  28148. dom_adapter_1.DOM.createElementNS(NAMESPACE_URIS[nsAndName[0]], nsAndName[1]) :
  28149. dom_adapter_1.DOM.createElement(nsAndName[1]);
  28150. this._setAttributes(el, attrNameAndValues);
  28151. return el;
  28152. };
  28153. DomRenderer_.prototype.mergeElement = function (existing, attrNameAndValues) {
  28154. dom_adapter_1.DOM.clearNodes(existing);
  28155. this._setAttributes(existing, attrNameAndValues);
  28156. };
  28157. DomRenderer_.prototype._setAttributes = function (node, attrNameAndValues) {
  28158. for (var attrIdx = 0; attrIdx < attrNameAndValues.length; attrIdx += 2) {
  28159. var attrNs;
  28160. var attrName = attrNameAndValues[attrIdx];
  28161. var nsAndName = splitNamespace(attrName);
  28162. if (lang_1.isPresent(nsAndName[0])) {
  28163. attrName = nsAndName[0] + ':' + nsAndName[1];
  28164. attrNs = NAMESPACE_URIS[nsAndName[0]];
  28165. }
  28166. var attrValue = attrNameAndValues[attrIdx + 1];
  28167. if (lang_1.isPresent(attrNs)) {
  28168. dom_adapter_1.DOM.setAttributeNS(node, attrNs, attrName, attrValue);
  28169. }
  28170. else {
  28171. dom_adapter_1.DOM.setAttribute(node, nsAndName[1], attrValue);
  28172. }
  28173. }
  28174. };
  28175. DomRenderer_.prototype.createRootContentInsertionPoint = function () {
  28176. return dom_adapter_1.DOM.createComment('root-content-insertion-point');
  28177. };
  28178. DomRenderer_.prototype.createShadowRoot = function (host, templateId) {
  28179. var sr = dom_adapter_1.DOM.createShadowRoot(host);
  28180. var tpl = this._componentTpls.get(templateId);
  28181. for (var i = 0; i < tpl.styles.length; i++) {
  28182. dom_adapter_1.DOM.appendChild(sr, dom_adapter_1.DOM.createStyleElement(tpl.styles[i]));
  28183. }
  28184. return sr;
  28185. };
  28186. DomRenderer_.prototype.on = function (element, eventName, callback) {
  28187. this._eventManager.addEventListener(element, eventName, decoratePreventDefault(callback));
  28188. };
  28189. DomRenderer_.prototype.globalOn = function (target, eventName, callback) {
  28190. return this._eventManager.addGlobalEventListener(target, eventName, decoratePreventDefault(callback));
  28191. };
  28192. DomRenderer_ = __decorate([
  28193. di_1.Injectable(),
  28194. __param(3, di_1.Inject(dom_tokens_1.DOCUMENT)),
  28195. __metadata('design:paramtypes', [event_manager_1.EventManager, shared_styles_host_1.DomSharedStylesHost, animation_builder_1.AnimationBuilder, Object])
  28196. ], DomRenderer_);
  28197. return DomRenderer_;
  28198. })(DomRenderer);
  28199. exports.DomRenderer_ = DomRenderer_;
  28200. function resolveInternalDomView(viewRef) {
  28201. return viewRef;
  28202. }
  28203. function resolveInternalDomFragment(fragmentRef) {
  28204. return fragmentRef.nodes;
  28205. }
  28206. function moveNodesAfterSibling(sibling, nodes) {
  28207. var parent = dom_adapter_1.DOM.parentElement(sibling);
  28208. if (nodes.length > 0 && lang_1.isPresent(parent)) {
  28209. var nextSibling = dom_adapter_1.DOM.nextSibling(sibling);
  28210. if (lang_1.isPresent(nextSibling)) {
  28211. for (var i = 0; i < nodes.length; i++) {
  28212. dom_adapter_1.DOM.insertBefore(nextSibling, nodes[i]);
  28213. }
  28214. }
  28215. else {
  28216. for (var i = 0; i < nodes.length; i++) {
  28217. dom_adapter_1.DOM.appendChild(parent, nodes[i]);
  28218. }
  28219. }
  28220. }
  28221. }
  28222. function decoratePreventDefault(eventHandler) {
  28223. return function (event) {
  28224. var allowDefaultBehavior = eventHandler(event);
  28225. if (!allowDefaultBehavior) {
  28226. // TODO(tbosch): move preventDefault into event plugins...
  28227. dom_adapter_1.DOM.preventDefault(event);
  28228. }
  28229. };
  28230. }
  28231. var NS_PREFIX_RE = /^@([^:]+):(.+)/g;
  28232. function splitNamespace(name) {
  28233. if (name[0] != '@') {
  28234. return [null, name];
  28235. }
  28236. var match = lang_1.RegExpWrapper.firstMatch(NS_PREFIX_RE, name);
  28237. return [match[1], match[2]];
  28238. }
  28239. /***/ },
  28240. /* 189 */
  28241. /***/ function(module, exports, __webpack_require__) {
  28242. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  28243. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  28244. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  28245. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  28246. return c > 3 && r && Object.defineProperty(target, key, r), r;
  28247. };
  28248. var __metadata = (this && this.__metadata) || function (k, v) {
  28249. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  28250. };
  28251. var di_1 = __webpack_require__(6);
  28252. var css_animation_builder_1 = __webpack_require__(190);
  28253. var browser_details_1 = __webpack_require__(195);
  28254. var AnimationBuilder = (function () {
  28255. /**
  28256. * Used for DI
  28257. * @param browserDetails
  28258. */
  28259. function AnimationBuilder(browserDetails) {
  28260. this.browserDetails = browserDetails;
  28261. }
  28262. /**
  28263. * Creates a new CSS Animation
  28264. * @returns {CssAnimationBuilder}
  28265. */
  28266. AnimationBuilder.prototype.css = function () { return new css_animation_builder_1.CssAnimationBuilder(this.browserDetails); };
  28267. AnimationBuilder = __decorate([
  28268. di_1.Injectable(),
  28269. __metadata('design:paramtypes', [browser_details_1.BrowserDetails])
  28270. ], AnimationBuilder);
  28271. return AnimationBuilder;
  28272. })();
  28273. exports.AnimationBuilder = AnimationBuilder;
  28274. /***/ },
  28275. /* 190 */
  28276. /***/ function(module, exports, __webpack_require__) {
  28277. var css_animation_options_1 = __webpack_require__(191);
  28278. var animation_1 = __webpack_require__(192);
  28279. var CssAnimationBuilder = (function () {
  28280. /**
  28281. * Accepts public properties for CssAnimationBuilder
  28282. */
  28283. function CssAnimationBuilder(browserDetails) {
  28284. this.browserDetails = browserDetails;
  28285. /** @type {CssAnimationOptions} */
  28286. this.data = new css_animation_options_1.CssAnimationOptions();
  28287. }
  28288. /**
  28289. * Adds a temporary class that will be removed at the end of the animation
  28290. * @param className
  28291. */
  28292. CssAnimationBuilder.prototype.addAnimationClass = function (className) {
  28293. this.data.animationClasses.push(className);
  28294. return this;
  28295. };
  28296. /**
  28297. * Adds a class that will remain on the element after the animation has finished
  28298. * @param className
  28299. */
  28300. CssAnimationBuilder.prototype.addClass = function (className) {
  28301. this.data.classesToAdd.push(className);
  28302. return this;
  28303. };
  28304. /**
  28305. * Removes a class from the element
  28306. * @param className
  28307. */
  28308. CssAnimationBuilder.prototype.removeClass = function (className) {
  28309. this.data.classesToRemove.push(className);
  28310. return this;
  28311. };
  28312. /**
  28313. * Sets the animation duration (and overrides any defined through CSS)
  28314. * @param duration
  28315. */
  28316. CssAnimationBuilder.prototype.setDuration = function (duration) {
  28317. this.data.duration = duration;
  28318. return this;
  28319. };
  28320. /**
  28321. * Sets the animation delay (and overrides any defined through CSS)
  28322. * @param delay
  28323. */
  28324. CssAnimationBuilder.prototype.setDelay = function (delay) {
  28325. this.data.delay = delay;
  28326. return this;
  28327. };
  28328. /**
  28329. * Sets styles for both the initial state and the destination state
  28330. * @param from
  28331. * @param to
  28332. */
  28333. CssAnimationBuilder.prototype.setStyles = function (from, to) {
  28334. return this.setFromStyles(from).setToStyles(to);
  28335. };
  28336. /**
  28337. * Sets the initial styles for the animation
  28338. * @param from
  28339. */
  28340. CssAnimationBuilder.prototype.setFromStyles = function (from) {
  28341. this.data.fromStyles = from;
  28342. return this;
  28343. };
  28344. /**
  28345. * Sets the destination styles for the animation
  28346. * @param to
  28347. */
  28348. CssAnimationBuilder.prototype.setToStyles = function (to) {
  28349. this.data.toStyles = to;
  28350. return this;
  28351. };
  28352. /**
  28353. * Starts the animation and returns a promise
  28354. * @param element
  28355. */
  28356. CssAnimationBuilder.prototype.start = function (element) {
  28357. return new animation_1.Animation(element, this.data, this.browserDetails);
  28358. };
  28359. return CssAnimationBuilder;
  28360. })();
  28361. exports.CssAnimationBuilder = CssAnimationBuilder;
  28362. /***/ },
  28363. /* 191 */
  28364. /***/ function(module, exports) {
  28365. var CssAnimationOptions = (function () {
  28366. function CssAnimationOptions() {
  28367. /** classes to be added to the element */
  28368. this.classesToAdd = [];
  28369. /** classes to be removed from the element */
  28370. this.classesToRemove = [];
  28371. /** classes to be added for the duration of the animation */
  28372. this.animationClasses = [];
  28373. }
  28374. return CssAnimationOptions;
  28375. })();
  28376. exports.CssAnimationOptions = CssAnimationOptions;
  28377. /***/ },
  28378. /* 192 */
  28379. /***/ function(module, exports, __webpack_require__) {
  28380. var lang_1 = __webpack_require__(5);
  28381. var math_1 = __webpack_require__(193);
  28382. var util_1 = __webpack_require__(194);
  28383. var collection_1 = __webpack_require__(12);
  28384. var dom_adapter_1 = __webpack_require__(178);
  28385. var Animation = (function () {
  28386. /**
  28387. * Stores the start time and starts the animation
  28388. * @param element
  28389. * @param data
  28390. * @param browserDetails
  28391. */
  28392. function Animation(element, data, browserDetails) {
  28393. var _this = this;
  28394. this.element = element;
  28395. this.data = data;
  28396. this.browserDetails = browserDetails;
  28397. /** functions to be called upon completion */
  28398. this.callbacks = [];
  28399. /** functions for removing event listeners */
  28400. this.eventClearFunctions = [];
  28401. /** flag used to track whether or not the animation has finished */
  28402. this.completed = false;
  28403. this._stringPrefix = '';
  28404. this.startTime = lang_1.DateWrapper.toMillis(lang_1.DateWrapper.now());
  28405. this._stringPrefix = dom_adapter_1.DOM.getAnimationPrefix();
  28406. this.setup();
  28407. this.wait(function (timestamp) { return _this.start(); });
  28408. }
  28409. Object.defineProperty(Animation.prototype, "totalTime", {
  28410. /** total amount of time that the animation should take including delay */
  28411. get: function () {
  28412. var delay = this.computedDelay != null ? this.computedDelay : 0;
  28413. var duration = this.computedDuration != null ? this.computedDuration : 0;
  28414. return delay + duration;
  28415. },
  28416. enumerable: true,
  28417. configurable: true
  28418. });
  28419. Animation.prototype.wait = function (callback) {
  28420. // Firefox requires 2 frames for some reason
  28421. this.browserDetails.raf(callback, 2);
  28422. };
  28423. /**
  28424. * Sets up the initial styles before the animation is started
  28425. */
  28426. Animation.prototype.setup = function () {
  28427. if (this.data.fromStyles != null)
  28428. this.applyStyles(this.data.fromStyles);
  28429. if (this.data.duration != null)
  28430. this.applyStyles({ 'transitionDuration': this.data.duration.toString() + 'ms' });
  28431. if (this.data.delay != null)
  28432. this.applyStyles({ 'transitionDelay': this.data.delay.toString() + 'ms' });
  28433. };
  28434. /**
  28435. * After the initial setup has occurred, this method adds the animation styles
  28436. */
  28437. Animation.prototype.start = function () {
  28438. this.addClasses(this.data.classesToAdd);
  28439. this.addClasses(this.data.animationClasses);
  28440. this.removeClasses(this.data.classesToRemove);
  28441. if (this.data.toStyles != null)
  28442. this.applyStyles(this.data.toStyles);
  28443. var computedStyles = dom_adapter_1.DOM.getComputedStyle(this.element);
  28444. this.computedDelay =
  28445. math_1.Math.max(this.parseDurationString(computedStyles.getPropertyValue(this._stringPrefix + 'transition-delay')), this.parseDurationString(this.element.style.getPropertyValue(this._stringPrefix + 'transition-delay')));
  28446. this.computedDuration = math_1.Math.max(this.parseDurationString(computedStyles.getPropertyValue(this._stringPrefix + 'transition-duration')), this.parseDurationString(this.element.style.getPropertyValue(this._stringPrefix + 'transition-duration')));
  28447. this.addEvents();
  28448. };
  28449. /**
  28450. * Applies the provided styles to the element
  28451. * @param styles
  28452. */
  28453. Animation.prototype.applyStyles = function (styles) {
  28454. var _this = this;
  28455. collection_1.StringMapWrapper.forEach(styles, function (value, key) {
  28456. var dashCaseKey = util_1.camelCaseToDashCase(key);
  28457. if (lang_1.isPresent(dom_adapter_1.DOM.getStyle(_this.element, dashCaseKey))) {
  28458. dom_adapter_1.DOM.setStyle(_this.element, dashCaseKey, value.toString());
  28459. }
  28460. else {
  28461. dom_adapter_1.DOM.setStyle(_this.element, _this._stringPrefix + dashCaseKey, value.toString());
  28462. }
  28463. });
  28464. };
  28465. /**
  28466. * Adds the provided classes to the element
  28467. * @param classes
  28468. */
  28469. Animation.prototype.addClasses = function (classes) {
  28470. for (var i = 0, len = classes.length; i < len; i++)
  28471. dom_adapter_1.DOM.addClass(this.element, classes[i]);
  28472. };
  28473. /**
  28474. * Removes the provided classes from the element
  28475. * @param classes
  28476. */
  28477. Animation.prototype.removeClasses = function (classes) {
  28478. for (var i = 0, len = classes.length; i < len; i++)
  28479. dom_adapter_1.DOM.removeClass(this.element, classes[i]);
  28480. };
  28481. /**
  28482. * Adds events to track when animations have finished
  28483. */
  28484. Animation.prototype.addEvents = function () {
  28485. var _this = this;
  28486. if (this.totalTime > 0) {
  28487. this.eventClearFunctions.push(dom_adapter_1.DOM.onAndCancel(this.element, dom_adapter_1.DOM.getTransitionEnd(), function (event) { return _this.handleAnimationEvent(event); }));
  28488. }
  28489. else {
  28490. this.handleAnimationCompleted();
  28491. }
  28492. };
  28493. Animation.prototype.handleAnimationEvent = function (event) {
  28494. var elapsedTime = math_1.Math.round(event.elapsedTime * 1000);
  28495. if (!this.browserDetails.elapsedTimeIncludesDelay)
  28496. elapsedTime += this.computedDelay;
  28497. event.stopPropagation();
  28498. if (elapsedTime >= this.totalTime)
  28499. this.handleAnimationCompleted();
  28500. };
  28501. /**
  28502. * Runs all animation callbacks and removes temporary classes
  28503. */
  28504. Animation.prototype.handleAnimationCompleted = function () {
  28505. this.removeClasses(this.data.animationClasses);
  28506. this.callbacks.forEach(function (callback) { return callback(); });
  28507. this.callbacks = [];
  28508. this.eventClearFunctions.forEach(function (fn) { return fn(); });
  28509. this.eventClearFunctions = [];
  28510. this.completed = true;
  28511. };
  28512. /**
  28513. * Adds animation callbacks to be called upon completion
  28514. * @param callback
  28515. * @returns {Animation}
  28516. */
  28517. Animation.prototype.onComplete = function (callback) {
  28518. if (this.completed) {
  28519. callback();
  28520. }
  28521. else {
  28522. this.callbacks.push(callback);
  28523. }
  28524. return this;
  28525. };
  28526. /**
  28527. * Converts the duration string to the number of milliseconds
  28528. * @param duration
  28529. * @returns {number}
  28530. */
  28531. Animation.prototype.parseDurationString = function (duration) {
  28532. var maxValue = 0;
  28533. // duration must have at least 2 characters to be valid. (number + type)
  28534. if (duration == null || duration.length < 2) {
  28535. return maxValue;
  28536. }
  28537. else if (duration.substring(duration.length - 2) == 'ms') {
  28538. var value = lang_1.NumberWrapper.parseInt(this.stripLetters(duration), 10);
  28539. if (value > maxValue)
  28540. maxValue = value;
  28541. }
  28542. else if (duration.substring(duration.length - 1) == 's') {
  28543. var ms = lang_1.NumberWrapper.parseFloat(this.stripLetters(duration)) * 1000;
  28544. var value = math_1.Math.floor(ms);
  28545. if (value > maxValue)
  28546. maxValue = value;
  28547. }
  28548. return maxValue;
  28549. };
  28550. /**
  28551. * Strips the letters from the duration string
  28552. * @param str
  28553. * @returns {string}
  28554. */
  28555. Animation.prototype.stripLetters = function (str) {
  28556. return lang_1.StringWrapper.replaceAll(str, lang_1.RegExpWrapper.create('[^0-9]+$', ''), '');
  28557. };
  28558. return Animation;
  28559. })();
  28560. exports.Animation = Animation;
  28561. /***/ },
  28562. /* 193 */
  28563. /***/ function(module, exports, __webpack_require__) {
  28564. var lang_1 = __webpack_require__(5);
  28565. exports.Math = lang_1.global.Math;
  28566. exports.NaN = typeof exports.NaN;
  28567. /***/ },
  28568. /* 194 */
  28569. /***/ function(module, exports, __webpack_require__) {
  28570. var lang_1 = __webpack_require__(5);
  28571. var CAMEL_CASE_REGEXP = /([A-Z])/g;
  28572. var DASH_CASE_REGEXP = /-([a-z])/g;
  28573. function camelCaseToDashCase(input) {
  28574. return lang_1.StringWrapper.replaceAllMapped(input, CAMEL_CASE_REGEXP, function (m) { return '-' + m[1].toLowerCase(); });
  28575. }
  28576. exports.camelCaseToDashCase = camelCaseToDashCase;
  28577. function dashCaseToCamelCase(input) {
  28578. return lang_1.StringWrapper.replaceAllMapped(input, DASH_CASE_REGEXP, function (m) { return m[1].toUpperCase(); });
  28579. }
  28580. exports.dashCaseToCamelCase = dashCaseToCamelCase;
  28581. /***/ },
  28582. /* 195 */
  28583. /***/ function(module, exports, __webpack_require__) {
  28584. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  28585. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  28586. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  28587. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  28588. return c > 3 && r && Object.defineProperty(target, key, r), r;
  28589. };
  28590. var __metadata = (this && this.__metadata) || function (k, v) {
  28591. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  28592. };
  28593. var di_1 = __webpack_require__(6);
  28594. var math_1 = __webpack_require__(193);
  28595. var dom_adapter_1 = __webpack_require__(178);
  28596. var BrowserDetails = (function () {
  28597. function BrowserDetails() {
  28598. this.elapsedTimeIncludesDelay = false;
  28599. this.doesElapsedTimeIncludesDelay();
  28600. }
  28601. /**
  28602. * Determines if `event.elapsedTime` includes transition delay in the current browser. At this
  28603. * time, Chrome and Opera seem to be the only browsers that include this.
  28604. */
  28605. BrowserDetails.prototype.doesElapsedTimeIncludesDelay = function () {
  28606. var _this = this;
  28607. var div = dom_adapter_1.DOM.createElement('div');
  28608. dom_adapter_1.DOM.setAttribute(div, 'style', "position: absolute; top: -9999px; left: -9999px; width: 1px;\n height: 1px; transition: all 1ms linear 1ms;");
  28609. // Firefox requires that we wait for 2 frames for some reason
  28610. this.raf(function (timestamp) {
  28611. dom_adapter_1.DOM.on(div, 'transitionend', function (event) {
  28612. var elapsed = math_1.Math.round(event.elapsedTime * 1000);
  28613. _this.elapsedTimeIncludesDelay = elapsed == 2;
  28614. dom_adapter_1.DOM.remove(div);
  28615. });
  28616. dom_adapter_1.DOM.setStyle(div, 'width', '2px');
  28617. }, 2);
  28618. };
  28619. BrowserDetails.prototype.raf = function (callback, frames) {
  28620. if (frames === void 0) { frames = 1; }
  28621. var queue = new RafQueue(callback, frames);
  28622. return function () { return queue.cancel(); };
  28623. };
  28624. BrowserDetails = __decorate([
  28625. di_1.Injectable(),
  28626. __metadata('design:paramtypes', [])
  28627. ], BrowserDetails);
  28628. return BrowserDetails;
  28629. })();
  28630. exports.BrowserDetails = BrowserDetails;
  28631. var RafQueue = (function () {
  28632. function RafQueue(callback, frames) {
  28633. this.callback = callback;
  28634. this.frames = frames;
  28635. this._raf();
  28636. }
  28637. RafQueue.prototype._raf = function () {
  28638. var _this = this;
  28639. this.currentFrameId = dom_adapter_1.DOM.requestAnimationFrame(function (timestamp) { return _this._nextFrame(timestamp); });
  28640. };
  28641. RafQueue.prototype._nextFrame = function (timestamp) {
  28642. this.frames--;
  28643. if (this.frames > 0) {
  28644. this._raf();
  28645. }
  28646. else {
  28647. this.callback(timestamp);
  28648. }
  28649. };
  28650. RafQueue.prototype.cancel = function () {
  28651. dom_adapter_1.DOM.cancelAnimationFrame(this.currentFrameId);
  28652. this.currentFrameId = null;
  28653. };
  28654. return RafQueue;
  28655. })();
  28656. /***/ },
  28657. /* 196 */
  28658. /***/ function(module, exports, __webpack_require__) {
  28659. var __extends = (this && this.__extends) || function (d, b) {
  28660. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  28661. function __() { this.constructor = d; }
  28662. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  28663. };
  28664. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  28665. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  28666. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  28667. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  28668. return c > 3 && r && Object.defineProperty(target, key, r), r;
  28669. };
  28670. var __metadata = (this && this.__metadata) || function (k, v) {
  28671. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  28672. };
  28673. var __param = (this && this.__param) || function (paramIndex, decorator) {
  28674. return function (target, key) { decorator(target, key, paramIndex); }
  28675. };
  28676. var dom_adapter_1 = __webpack_require__(178);
  28677. var di_1 = __webpack_require__(6);
  28678. var collection_1 = __webpack_require__(12);
  28679. var dom_tokens_1 = __webpack_require__(187);
  28680. var SharedStylesHost = (function () {
  28681. function SharedStylesHost() {
  28682. /** @internal */
  28683. this._styles = [];
  28684. /** @internal */
  28685. this._stylesSet = new Set();
  28686. }
  28687. SharedStylesHost.prototype.addStyles = function (styles) {
  28688. var _this = this;
  28689. var additions = [];
  28690. styles.forEach(function (style) {
  28691. if (!collection_1.SetWrapper.has(_this._stylesSet, style)) {
  28692. _this._stylesSet.add(style);
  28693. _this._styles.push(style);
  28694. additions.push(style);
  28695. }
  28696. });
  28697. this.onStylesAdded(additions);
  28698. };
  28699. SharedStylesHost.prototype.onStylesAdded = function (additions) { };
  28700. SharedStylesHost.prototype.getAllStyles = function () { return this._styles; };
  28701. SharedStylesHost = __decorate([
  28702. di_1.Injectable(),
  28703. __metadata('design:paramtypes', [])
  28704. ], SharedStylesHost);
  28705. return SharedStylesHost;
  28706. })();
  28707. exports.SharedStylesHost = SharedStylesHost;
  28708. var DomSharedStylesHost = (function (_super) {
  28709. __extends(DomSharedStylesHost, _super);
  28710. function DomSharedStylesHost(doc) {
  28711. _super.call(this);
  28712. this._hostNodes = new Set();
  28713. this._hostNodes.add(doc.head);
  28714. }
  28715. /** @internal */
  28716. DomSharedStylesHost.prototype._addStylesToHost = function (styles, host) {
  28717. for (var i = 0; i < styles.length; i++) {
  28718. var style = styles[i];
  28719. dom_adapter_1.DOM.appendChild(host, dom_adapter_1.DOM.createStyleElement(style));
  28720. }
  28721. };
  28722. DomSharedStylesHost.prototype.addHost = function (hostNode) {
  28723. this._addStylesToHost(this._styles, hostNode);
  28724. this._hostNodes.add(hostNode);
  28725. };
  28726. DomSharedStylesHost.prototype.removeHost = function (hostNode) { collection_1.SetWrapper.delete(this._hostNodes, hostNode); };
  28727. DomSharedStylesHost.prototype.onStylesAdded = function (additions) {
  28728. var _this = this;
  28729. this._hostNodes.forEach(function (hostNode) { _this._addStylesToHost(additions, hostNode); });
  28730. };
  28731. DomSharedStylesHost = __decorate([
  28732. di_1.Injectable(),
  28733. __param(0, di_1.Inject(dom_tokens_1.DOCUMENT)),
  28734. __metadata('design:paramtypes', [Object])
  28735. ], DomSharedStylesHost);
  28736. return DomSharedStylesHost;
  28737. })(SharedStylesHost);
  28738. exports.DomSharedStylesHost = DomSharedStylesHost;
  28739. /***/ },
  28740. /* 197 */
  28741. /***/ function(module, exports, __webpack_require__) {
  28742. var __extends = (this && this.__extends) || function (d, b) {
  28743. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  28744. function __() { this.constructor = d; }
  28745. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  28746. };
  28747. var collection_1 = __webpack_require__(12);
  28748. var lang_1 = __webpack_require__(5);
  28749. var dom_adapter_1 = __webpack_require__(178);
  28750. var generic_browser_adapter_1 = __webpack_require__(198);
  28751. var _attrToPropMap = {
  28752. 'class': 'className',
  28753. 'innerHtml': 'innerHTML',
  28754. 'readonly': 'readOnly',
  28755. 'tabindex': 'tabIndex'
  28756. };
  28757. var DOM_KEY_LOCATION_NUMPAD = 3;
  28758. // Map to convert some key or keyIdentifier values to what will be returned by getEventKey
  28759. var _keyMap = {
  28760. // The following values are here for cross-browser compatibility and to match the W3C standard
  28761. // cf http://www.w3.org/TR/DOM-Level-3-Events-key/
  28762. '\b': 'Backspace',
  28763. '\t': 'Tab',
  28764. '\x7F': 'Delete',
  28765. '\x1B': 'Escape',
  28766. 'Del': 'Delete',
  28767. 'Esc': 'Escape',
  28768. 'Left': 'ArrowLeft',
  28769. 'Right': 'ArrowRight',
  28770. 'Up': 'ArrowUp',
  28771. 'Down': 'ArrowDown',
  28772. 'Menu': 'ContextMenu',
  28773. 'Scroll': 'ScrollLock',
  28774. 'Win': 'OS'
  28775. };
  28776. // There is a bug in Chrome for numeric keypad keys:
  28777. // https://code.google.com/p/chromium/issues/detail?id=155654
  28778. // 1, 2, 3 ... are reported as A, B, C ...
  28779. var _chromeNumKeyPadMap = {
  28780. 'A': '1',
  28781. 'B': '2',
  28782. 'C': '3',
  28783. 'D': '4',
  28784. 'E': '5',
  28785. 'F': '6',
  28786. 'G': '7',
  28787. 'H': '8',
  28788. 'I': '9',
  28789. 'J': '*',
  28790. 'K': '+',
  28791. 'M': '-',
  28792. 'N': '.',
  28793. 'O': '/',
  28794. '\x60': '0',
  28795. '\x90': 'NumLock'
  28796. };
  28797. /**
  28798. * A `DomAdapter` powered by full browser DOM APIs.
  28799. */
  28800. /* tslint:disable:requireParameterType */
  28801. var BrowserDomAdapter = (function (_super) {
  28802. __extends(BrowserDomAdapter, _super);
  28803. function BrowserDomAdapter() {
  28804. _super.apply(this, arguments);
  28805. }
  28806. BrowserDomAdapter.prototype.parse = function (templateHtml) { throw new Error("parse not implemented"); };
  28807. BrowserDomAdapter.makeCurrent = function () { dom_adapter_1.setRootDomAdapter(new BrowserDomAdapter()); };
  28808. BrowserDomAdapter.prototype.hasProperty = function (element, name) { return name in element; };
  28809. BrowserDomAdapter.prototype.setProperty = function (el, name, value) { el[name] = value; };
  28810. BrowserDomAdapter.prototype.getProperty = function (el, name) { return el[name]; };
  28811. BrowserDomAdapter.prototype.invoke = function (el, methodName, args) {
  28812. el[methodName].apply(el, args);
  28813. };
  28814. // TODO(tbosch): move this into a separate environment class once we have it
  28815. BrowserDomAdapter.prototype.logError = function (error) {
  28816. if (window.console.error) {
  28817. window.console.error(error);
  28818. }
  28819. else {
  28820. window.console.log(error);
  28821. }
  28822. };
  28823. BrowserDomAdapter.prototype.log = function (error) { window.console.log(error); };
  28824. BrowserDomAdapter.prototype.logGroup = function (error) {
  28825. if (window.console.group) {
  28826. window.console.group(error);
  28827. this.logError(error);
  28828. }
  28829. else {
  28830. window.console.log(error);
  28831. }
  28832. };
  28833. BrowserDomAdapter.prototype.logGroupEnd = function () {
  28834. if (window.console.groupEnd) {
  28835. window.console.groupEnd();
  28836. }
  28837. };
  28838. Object.defineProperty(BrowserDomAdapter.prototype, "attrToPropMap", {
  28839. get: function () { return _attrToPropMap; },
  28840. enumerable: true,
  28841. configurable: true
  28842. });
  28843. BrowserDomAdapter.prototype.query = function (selector) { return document.querySelector(selector); };
  28844. BrowserDomAdapter.prototype.querySelector = function (el, selector) { return el.querySelector(selector); };
  28845. BrowserDomAdapter.prototype.querySelectorAll = function (el, selector) { return el.querySelectorAll(selector); };
  28846. BrowserDomAdapter.prototype.on = function (el, evt, listener) { el.addEventListener(evt, listener, false); };
  28847. BrowserDomAdapter.prototype.onAndCancel = function (el, evt, listener) {
  28848. el.addEventListener(evt, listener, false);
  28849. // Needed to follow Dart's subscription semantic, until fix of
  28850. // https://code.google.com/p/dart/issues/detail?id=17406
  28851. return function () { el.removeEventListener(evt, listener, false); };
  28852. };
  28853. BrowserDomAdapter.prototype.dispatchEvent = function (el, evt) { el.dispatchEvent(evt); };
  28854. BrowserDomAdapter.prototype.createMouseEvent = function (eventType) {
  28855. var evt = document.createEvent('MouseEvent');
  28856. evt.initEvent(eventType, true, true);
  28857. return evt;
  28858. };
  28859. BrowserDomAdapter.prototype.createEvent = function (eventType) {
  28860. var evt = document.createEvent('Event');
  28861. evt.initEvent(eventType, true, true);
  28862. return evt;
  28863. };
  28864. BrowserDomAdapter.prototype.preventDefault = function (evt) {
  28865. evt.preventDefault();
  28866. evt.returnValue = false;
  28867. };
  28868. BrowserDomAdapter.prototype.isPrevented = function (evt) {
  28869. return evt.defaultPrevented || lang_1.isPresent(evt.returnValue) && !evt.returnValue;
  28870. };
  28871. BrowserDomAdapter.prototype.getInnerHTML = function (el) { return el.innerHTML; };
  28872. BrowserDomAdapter.prototype.getOuterHTML = function (el) { return el.outerHTML; };
  28873. BrowserDomAdapter.prototype.nodeName = function (node) { return node.nodeName; };
  28874. BrowserDomAdapter.prototype.nodeValue = function (node) { return node.nodeValue; };
  28875. BrowserDomAdapter.prototype.type = function (node) { return node.type; };
  28876. BrowserDomAdapter.prototype.content = function (node) {
  28877. if (this.hasProperty(node, "content")) {
  28878. return node.content;
  28879. }
  28880. else {
  28881. return node;
  28882. }
  28883. };
  28884. BrowserDomAdapter.prototype.firstChild = function (el) { return el.firstChild; };
  28885. BrowserDomAdapter.prototype.nextSibling = function (el) { return el.nextSibling; };
  28886. BrowserDomAdapter.prototype.parentElement = function (el) { return el.parentNode; };
  28887. BrowserDomAdapter.prototype.childNodes = function (el) { return el.childNodes; };
  28888. BrowserDomAdapter.prototype.childNodesAsList = function (el) {
  28889. var childNodes = el.childNodes;
  28890. var res = collection_1.ListWrapper.createFixedSize(childNodes.length);
  28891. for (var i = 0; i < childNodes.length; i++) {
  28892. res[i] = childNodes[i];
  28893. }
  28894. return res;
  28895. };
  28896. BrowserDomAdapter.prototype.clearNodes = function (el) {
  28897. while (el.firstChild) {
  28898. el.removeChild(el.firstChild);
  28899. }
  28900. };
  28901. BrowserDomAdapter.prototype.appendChild = function (el, node) { el.appendChild(node); };
  28902. BrowserDomAdapter.prototype.removeChild = function (el, node) { el.removeChild(node); };
  28903. BrowserDomAdapter.prototype.replaceChild = function (el, newChild, oldChild) { el.replaceChild(newChild, oldChild); };
  28904. BrowserDomAdapter.prototype.remove = function (node) {
  28905. if (node.parentNode) {
  28906. node.parentNode.removeChild(node);
  28907. }
  28908. return node;
  28909. };
  28910. BrowserDomAdapter.prototype.insertBefore = function (el, node) { el.parentNode.insertBefore(node, el); };
  28911. BrowserDomAdapter.prototype.insertAllBefore = function (el, nodes) { nodes.forEach(function (n) { return el.parentNode.insertBefore(n, el); }); };
  28912. BrowserDomAdapter.prototype.insertAfter = function (el, node) { el.parentNode.insertBefore(node, el.nextSibling); };
  28913. BrowserDomAdapter.prototype.setInnerHTML = function (el, value) { el.innerHTML = value; };
  28914. BrowserDomAdapter.prototype.getText = function (el) { return el.textContent; };
  28915. // TODO(vicb): removed Element type because it does not support StyleElement
  28916. BrowserDomAdapter.prototype.setText = function (el, value) { el.textContent = value; };
  28917. BrowserDomAdapter.prototype.getValue = function (el) { return el.value; };
  28918. BrowserDomAdapter.prototype.setValue = function (el, value) { el.value = value; };
  28919. BrowserDomAdapter.prototype.getChecked = function (el) { return el.checked; };
  28920. BrowserDomAdapter.prototype.setChecked = function (el, value) { el.checked = value; };
  28921. BrowserDomAdapter.prototype.createComment = function (text) { return document.createComment(text); };
  28922. BrowserDomAdapter.prototype.createTemplate = function (html) {
  28923. var t = document.createElement('template');
  28924. t.innerHTML = html;
  28925. return t;
  28926. };
  28927. BrowserDomAdapter.prototype.createElement = function (tagName, doc) {
  28928. if (doc === void 0) { doc = document; }
  28929. return doc.createElement(tagName);
  28930. };
  28931. BrowserDomAdapter.prototype.createElementNS = function (ns, tagName, doc) {
  28932. if (doc === void 0) { doc = document; }
  28933. return doc.createElementNS(ns, tagName);
  28934. };
  28935. BrowserDomAdapter.prototype.createTextNode = function (text, doc) {
  28936. if (doc === void 0) { doc = document; }
  28937. return doc.createTextNode(text);
  28938. };
  28939. BrowserDomAdapter.prototype.createScriptTag = function (attrName, attrValue, doc) {
  28940. if (doc === void 0) { doc = document; }
  28941. var el = doc.createElement('SCRIPT');
  28942. el.setAttribute(attrName, attrValue);
  28943. return el;
  28944. };
  28945. BrowserDomAdapter.prototype.createStyleElement = function (css, doc) {
  28946. if (doc === void 0) { doc = document; }
  28947. var style = doc.createElement('style');
  28948. this.appendChild(style, this.createTextNode(css));
  28949. return style;
  28950. };
  28951. BrowserDomAdapter.prototype.createShadowRoot = function (el) { return el.createShadowRoot(); };
  28952. BrowserDomAdapter.prototype.getShadowRoot = function (el) { return el.shadowRoot; };
  28953. BrowserDomAdapter.prototype.getHost = function (el) { return el.host; };
  28954. BrowserDomAdapter.prototype.clone = function (node) { return node.cloneNode(true); };
  28955. BrowserDomAdapter.prototype.getElementsByClassName = function (element, name) {
  28956. return element.getElementsByClassName(name);
  28957. };
  28958. BrowserDomAdapter.prototype.getElementsByTagName = function (element, name) {
  28959. return element.getElementsByTagName(name);
  28960. };
  28961. BrowserDomAdapter.prototype.classList = function (element) { return Array.prototype.slice.call(element.classList, 0); };
  28962. BrowserDomAdapter.prototype.addClass = function (element, className) { element.classList.add(className); };
  28963. BrowserDomAdapter.prototype.removeClass = function (element, className) { element.classList.remove(className); };
  28964. BrowserDomAdapter.prototype.hasClass = function (element, className) { return element.classList.contains(className); };
  28965. BrowserDomAdapter.prototype.setStyle = function (element, styleName, styleValue) {
  28966. element.style[styleName] = styleValue;
  28967. };
  28968. BrowserDomAdapter.prototype.removeStyle = function (element, stylename) { element.style[stylename] = null; };
  28969. BrowserDomAdapter.prototype.getStyle = function (element, stylename) { return element.style[stylename]; };
  28970. BrowserDomAdapter.prototype.hasStyle = function (element, styleName, styleValue) {
  28971. if (styleValue === void 0) { styleValue = null; }
  28972. var value = this.getStyle(element, styleName) || '';
  28973. return styleValue ? value == styleValue : value.length > 0;
  28974. };
  28975. BrowserDomAdapter.prototype.tagName = function (element) { return element.tagName; };
  28976. BrowserDomAdapter.prototype.attributeMap = function (element) {
  28977. var res = new Map();
  28978. var elAttrs = element.attributes;
  28979. for (var i = 0; i < elAttrs.length; i++) {
  28980. var attrib = elAttrs[i];
  28981. res.set(attrib.name, attrib.value);
  28982. }
  28983. return res;
  28984. };
  28985. BrowserDomAdapter.prototype.hasAttribute = function (element, attribute) { return element.hasAttribute(attribute); };
  28986. BrowserDomAdapter.prototype.getAttribute = function (element, attribute) { return element.getAttribute(attribute); };
  28987. BrowserDomAdapter.prototype.setAttribute = function (element, name, value) { element.setAttribute(name, value); };
  28988. BrowserDomAdapter.prototype.setAttributeNS = function (element, ns, name, value) {
  28989. element.setAttributeNS(ns, name, value);
  28990. };
  28991. BrowserDomAdapter.prototype.removeAttribute = function (element, attribute) { element.removeAttribute(attribute); };
  28992. BrowserDomAdapter.prototype.templateAwareRoot = function (el) { return this.isTemplateElement(el) ? this.content(el) : el; };
  28993. BrowserDomAdapter.prototype.createHtmlDocument = function () {
  28994. return document.implementation.createHTMLDocument('fakeTitle');
  28995. };
  28996. BrowserDomAdapter.prototype.defaultDoc = function () { return document; };
  28997. BrowserDomAdapter.prototype.getBoundingClientRect = function (el) {
  28998. try {
  28999. return el.getBoundingClientRect();
  29000. }
  29001. catch (e) {
  29002. return { top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0 };
  29003. }
  29004. };
  29005. BrowserDomAdapter.prototype.getTitle = function () { return document.title; };
  29006. BrowserDomAdapter.prototype.setTitle = function (newTitle) { document.title = newTitle || ''; };
  29007. BrowserDomAdapter.prototype.elementMatches = function (n, selector) {
  29008. var matches = false;
  29009. if (n instanceof HTMLElement) {
  29010. if (n.matches) {
  29011. matches = n.matches(selector);
  29012. }
  29013. else if (n.msMatchesSelector) {
  29014. matches = n.msMatchesSelector(selector);
  29015. }
  29016. else if (n.webkitMatchesSelector) {
  29017. matches = n.webkitMatchesSelector(selector);
  29018. }
  29019. }
  29020. return matches;
  29021. };
  29022. BrowserDomAdapter.prototype.isTemplateElement = function (el) {
  29023. return el instanceof HTMLElement && el.nodeName == "TEMPLATE";
  29024. };
  29025. BrowserDomAdapter.prototype.isTextNode = function (node) { return node.nodeType === Node.TEXT_NODE; };
  29026. BrowserDomAdapter.prototype.isCommentNode = function (node) { return node.nodeType === Node.COMMENT_NODE; };
  29027. BrowserDomAdapter.prototype.isElementNode = function (node) { return node.nodeType === Node.ELEMENT_NODE; };
  29028. BrowserDomAdapter.prototype.hasShadowRoot = function (node) { return node instanceof HTMLElement && lang_1.isPresent(node.shadowRoot); };
  29029. BrowserDomAdapter.prototype.isShadowRoot = function (node) { return node instanceof DocumentFragment; };
  29030. BrowserDomAdapter.prototype.importIntoDoc = function (node) {
  29031. var toImport = node;
  29032. if (this.isTemplateElement(node)) {
  29033. toImport = this.content(node);
  29034. }
  29035. return document.importNode(toImport, true);
  29036. };
  29037. BrowserDomAdapter.prototype.adoptNode = function (node) { return document.adoptNode(node); };
  29038. BrowserDomAdapter.prototype.getHref = function (el) { return el.href; };
  29039. BrowserDomAdapter.prototype.getEventKey = function (event) {
  29040. var key = event.key;
  29041. if (lang_1.isBlank(key)) {
  29042. key = event.keyIdentifier;
  29043. // keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and
  29044. // Safari
  29045. // cf
  29046. // http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces
  29047. if (lang_1.isBlank(key)) {
  29048. return 'Unidentified';
  29049. }
  29050. if (key.startsWith('U+')) {
  29051. key = String.fromCharCode(parseInt(key.substring(2), 16));
  29052. if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
  29053. // There is a bug in Chrome for numeric keypad keys:
  29054. // https://code.google.com/p/chromium/issues/detail?id=155654
  29055. // 1, 2, 3 ... are reported as A, B, C ...
  29056. key = _chromeNumKeyPadMap[key];
  29057. }
  29058. }
  29059. }
  29060. if (_keyMap.hasOwnProperty(key)) {
  29061. key = _keyMap[key];
  29062. }
  29063. return key;
  29064. };
  29065. BrowserDomAdapter.prototype.getGlobalEventTarget = function (target) {
  29066. if (target == "window") {
  29067. return window;
  29068. }
  29069. else if (target == "document") {
  29070. return document;
  29071. }
  29072. else if (target == "body") {
  29073. return document.body;
  29074. }
  29075. };
  29076. BrowserDomAdapter.prototype.getHistory = function () { return window.history; };
  29077. BrowserDomAdapter.prototype.getLocation = function () { return window.location; };
  29078. BrowserDomAdapter.prototype.getBaseHref = function () {
  29079. var href = getBaseElementHref();
  29080. if (lang_1.isBlank(href)) {
  29081. return null;
  29082. }
  29083. return relativePath(href);
  29084. };
  29085. BrowserDomAdapter.prototype.resetBaseElement = function () { baseElement = null; };
  29086. BrowserDomAdapter.prototype.getUserAgent = function () { return window.navigator.userAgent; };
  29087. BrowserDomAdapter.prototype.setData = function (element, name, value) {
  29088. this.setAttribute(element, 'data-' + name, value);
  29089. };
  29090. BrowserDomAdapter.prototype.getData = function (element, name) { return this.getAttribute(element, 'data-' + name); };
  29091. BrowserDomAdapter.prototype.getComputedStyle = function (element) { return getComputedStyle(element); };
  29092. // TODO(tbosch): move this into a separate environment class once we have it
  29093. BrowserDomAdapter.prototype.setGlobalVar = function (path, value) { lang_1.setValueOnPath(lang_1.global, path, value); };
  29094. BrowserDomAdapter.prototype.requestAnimationFrame = function (callback) { return window.requestAnimationFrame(callback); };
  29095. BrowserDomAdapter.prototype.cancelAnimationFrame = function (id) { window.cancelAnimationFrame(id); };
  29096. BrowserDomAdapter.prototype.performanceNow = function () {
  29097. // performance.now() is not available in all browsers, see
  29098. // http://caniuse.com/#search=performance.now
  29099. if (lang_1.isPresent(window.performance) && lang_1.isPresent(window.performance.now)) {
  29100. return window.performance.now();
  29101. }
  29102. else {
  29103. return lang_1.DateWrapper.toMillis(lang_1.DateWrapper.now());
  29104. }
  29105. };
  29106. return BrowserDomAdapter;
  29107. })(generic_browser_adapter_1.GenericBrowserDomAdapter);
  29108. exports.BrowserDomAdapter = BrowserDomAdapter;
  29109. var baseElement = null;
  29110. function getBaseElementHref() {
  29111. if (lang_1.isBlank(baseElement)) {
  29112. baseElement = document.querySelector('base');
  29113. if (lang_1.isBlank(baseElement)) {
  29114. return null;
  29115. }
  29116. }
  29117. return baseElement.getAttribute('href');
  29118. }
  29119. // based on urlUtils.js in AngularJS 1
  29120. var urlParsingNode = null;
  29121. function relativePath(url) {
  29122. if (lang_1.isBlank(urlParsingNode)) {
  29123. urlParsingNode = document.createElement("a");
  29124. }
  29125. urlParsingNode.setAttribute('href', url);
  29126. return (urlParsingNode.pathname.charAt(0) === '/') ? urlParsingNode.pathname :
  29127. '/' + urlParsingNode.pathname;
  29128. }
  29129. /***/ },
  29130. /* 198 */
  29131. /***/ function(module, exports, __webpack_require__) {
  29132. var __extends = (this && this.__extends) || function (d, b) {
  29133. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  29134. function __() { this.constructor = d; }
  29135. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29136. };
  29137. var collection_1 = __webpack_require__(12);
  29138. var lang_1 = __webpack_require__(5);
  29139. var dom_adapter_1 = __webpack_require__(178);
  29140. var xhr_impl_1 = __webpack_require__(199);
  29141. /**
  29142. * Provides DOM operations in any browser environment.
  29143. */
  29144. var GenericBrowserDomAdapter = (function (_super) {
  29145. __extends(GenericBrowserDomAdapter, _super);
  29146. function GenericBrowserDomAdapter() {
  29147. var _this = this;
  29148. _super.call(this);
  29149. this._animationPrefix = null;
  29150. this._transitionEnd = null;
  29151. try {
  29152. var element = this.createElement('div', this.defaultDoc());
  29153. if (lang_1.isPresent(this.getStyle(element, 'animationName'))) {
  29154. this._animationPrefix = '';
  29155. }
  29156. else {
  29157. var domPrefixes = ['Webkit', 'Moz', 'O', 'ms'];
  29158. for (var i = 0; i < domPrefixes.length; i++) {
  29159. if (lang_1.isPresent(this.getStyle(element, domPrefixes[i] + 'AnimationName'))) {
  29160. this._animationPrefix = '-' + domPrefixes[i].toLowerCase() + '-';
  29161. break;
  29162. }
  29163. }
  29164. }
  29165. var transEndEventNames = {
  29166. WebkitTransition: 'webkitTransitionEnd',
  29167. MozTransition: 'transitionend',
  29168. OTransition: 'oTransitionEnd otransitionend',
  29169. transition: 'transitionend'
  29170. };
  29171. collection_1.StringMapWrapper.forEach(transEndEventNames, function (value, key) {
  29172. if (lang_1.isPresent(_this.getStyle(element, key))) {
  29173. _this._transitionEnd = value;
  29174. }
  29175. });
  29176. }
  29177. catch (e) {
  29178. this._animationPrefix = null;
  29179. this._transitionEnd = null;
  29180. }
  29181. }
  29182. GenericBrowserDomAdapter.prototype.getXHR = function () { return xhr_impl_1.XHRImpl; };
  29183. GenericBrowserDomAdapter.prototype.getDistributedNodes = function (el) { return el.getDistributedNodes(); };
  29184. GenericBrowserDomAdapter.prototype.resolveAndSetHref = function (el, baseUrl, href) {
  29185. el.href = href == null ? baseUrl : baseUrl + '/../' + href;
  29186. };
  29187. GenericBrowserDomAdapter.prototype.supportsDOMEvents = function () { return true; };
  29188. GenericBrowserDomAdapter.prototype.supportsNativeShadowDOM = function () {
  29189. return lang_1.isFunction(this.defaultDoc().body.createShadowRoot);
  29190. };
  29191. GenericBrowserDomAdapter.prototype.getAnimationPrefix = function () {
  29192. return lang_1.isPresent(this._animationPrefix) ? this._animationPrefix : "";
  29193. };
  29194. GenericBrowserDomAdapter.prototype.getTransitionEnd = function () { return lang_1.isPresent(this._transitionEnd) ? this._transitionEnd : ""; };
  29195. GenericBrowserDomAdapter.prototype.supportsAnimation = function () {
  29196. return lang_1.isPresent(this._animationPrefix) && lang_1.isPresent(this._transitionEnd);
  29197. };
  29198. return GenericBrowserDomAdapter;
  29199. })(dom_adapter_1.DomAdapter);
  29200. exports.GenericBrowserDomAdapter = GenericBrowserDomAdapter;
  29201. /***/ },
  29202. /* 199 */
  29203. /***/ function(module, exports, __webpack_require__) {
  29204. var __extends = (this && this.__extends) || function (d, b) {
  29205. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  29206. function __() { this.constructor = d; }
  29207. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29208. };
  29209. var promise_1 = __webpack_require__(61);
  29210. var lang_1 = __webpack_require__(5);
  29211. var xhr_1 = __webpack_require__(149);
  29212. var XHRImpl = (function (_super) {
  29213. __extends(XHRImpl, _super);
  29214. function XHRImpl() {
  29215. _super.apply(this, arguments);
  29216. }
  29217. XHRImpl.prototype.get = function (url) {
  29218. var completer = promise_1.PromiseWrapper.completer();
  29219. var xhr = new XMLHttpRequest();
  29220. xhr.open('GET', url, true);
  29221. xhr.responseType = 'text';
  29222. xhr.onload = function () {
  29223. // responseText is the old-school way of retrieving response (supported by IE8 & 9)
  29224. // response/responseType properties were introduced in XHR Level2 spec (supported by IE10)
  29225. var response = lang_1.isPresent(xhr.response) ? xhr.response : xhr.responseText;
  29226. // normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
  29227. var status = xhr.status === 1223 ? 204 : xhr.status;
  29228. // fix status code when it is 0 (0 status is undocumented).
  29229. // Occurs when accessing file resources or on Android 4.1 stock browser
  29230. // while retrieving files from application cache.
  29231. if (status === 0) {
  29232. status = response ? 200 : 0;
  29233. }
  29234. if (200 <= status && status <= 300) {
  29235. completer.resolve(response);
  29236. }
  29237. else {
  29238. completer.reject("Failed to load " + url, null);
  29239. }
  29240. };
  29241. xhr.onerror = function () { completer.reject("Failed to load " + url, null); };
  29242. xhr.send();
  29243. return completer.promise;
  29244. };
  29245. return XHRImpl;
  29246. })(xhr_1.XHR);
  29247. exports.XHRImpl = XHRImpl;
  29248. /***/ },
  29249. /* 200 */
  29250. /***/ function(module, exports, __webpack_require__) {
  29251. var lang_1 = __webpack_require__(5);
  29252. var dom_adapter_1 = __webpack_require__(178);
  29253. var core_1 = __webpack_require__(2);
  29254. var PublicTestability = (function () {
  29255. function PublicTestability(testability) {
  29256. this._testability = testability;
  29257. }
  29258. PublicTestability.prototype.isStable = function () { return this._testability.isStable(); };
  29259. PublicTestability.prototype.whenStable = function (callback) { this._testability.whenStable(callback); };
  29260. PublicTestability.prototype.findBindings = function (using, provider, exactMatch) {
  29261. return this.findProviders(using, provider, exactMatch);
  29262. };
  29263. PublicTestability.prototype.findProviders = function (using, provider, exactMatch) {
  29264. return this._testability.findBindings(using, provider, exactMatch);
  29265. };
  29266. return PublicTestability;
  29267. })();
  29268. var BrowserGetTestability = (function () {
  29269. function BrowserGetTestability() {
  29270. }
  29271. BrowserGetTestability.init = function () { core_1.setTestabilityGetter(new BrowserGetTestability()); };
  29272. BrowserGetTestability.prototype.addToWindow = function (registry) {
  29273. lang_1.global.getAngularTestability = function (elem, findInAncestors) {
  29274. if (findInAncestors === void 0) { findInAncestors = true; }
  29275. var testability = registry.findTestabilityInTree(elem, findInAncestors);
  29276. if (testability == null) {
  29277. throw new Error('Could not find testability for element.');
  29278. }
  29279. return new PublicTestability(testability);
  29280. };
  29281. lang_1.global.getAllAngularTestabilities = function () {
  29282. var testabilities = registry.getAllTestabilities();
  29283. return testabilities.map(function (testability) { return new PublicTestability(testability); });
  29284. };
  29285. };
  29286. BrowserGetTestability.prototype.findTestabilityInTree = function (registry, elem, findInAncestors) {
  29287. if (elem == null) {
  29288. return null;
  29289. }
  29290. var t = registry.getTestability(elem);
  29291. if (lang_1.isPresent(t)) {
  29292. return t;
  29293. }
  29294. else if (!findInAncestors) {
  29295. return null;
  29296. }
  29297. if (dom_adapter_1.DOM.isShadowRoot(elem)) {
  29298. return this.findTestabilityInTree(registry, dom_adapter_1.DOM.getHost(elem), true);
  29299. }
  29300. return this.findTestabilityInTree(registry, dom_adapter_1.DOM.parentElement(elem), true);
  29301. };
  29302. return BrowserGetTestability;
  29303. })();
  29304. exports.BrowserGetTestability = BrowserGetTestability;
  29305. /***/ },
  29306. /* 201 */
  29307. /***/ function(module, exports) {
  29308. /**
  29309. * This is here because DART requires it. It is noop in JS.
  29310. */
  29311. function wtfInit() { }
  29312. exports.wtfInit = wtfInit;
  29313. /***/ },
  29314. /* 202 */
  29315. /***/ function(module, exports, __webpack_require__) {
  29316. var dom_adapter_1 = __webpack_require__(178);
  29317. /**
  29318. * A service that can be used to get and set the title of a current HTML document.
  29319. *
  29320. * Since an Angular 2 application can't be bootstrapped on the entire HTML document (`<html>` tag)
  29321. * it is not possible to bind to the `text` property of the `HTMLTitleElement` elements
  29322. * (representing the `<title>` tag). Instead, this service can be used to set and get the current
  29323. * title value.
  29324. */
  29325. var Title = (function () {
  29326. function Title() {
  29327. }
  29328. /**
  29329. * Get the title of the current HTML document.
  29330. * @returns {string}
  29331. */
  29332. Title.prototype.getTitle = function () { return dom_adapter_1.DOM.getTitle(); };
  29333. /**
  29334. * Set the title of the current HTML document.
  29335. * @param newTitle
  29336. */
  29337. Title.prototype.setTitle = function (newTitle) { dom_adapter_1.DOM.setTitle(newTitle); };
  29338. return Title;
  29339. })();
  29340. exports.Title = Title;
  29341. /***/ },
  29342. /* 203 */
  29343. /***/ function(module, exports, __webpack_require__) {
  29344. function __export(m) {
  29345. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  29346. }
  29347. /**
  29348. * This is a set of classes and objects that can be used both in the browser and on the server.
  29349. */
  29350. var dom_adapter_1 = __webpack_require__(178);
  29351. exports.DOM = dom_adapter_1.DOM;
  29352. exports.setRootDomAdapter = dom_adapter_1.setRootDomAdapter;
  29353. exports.DomAdapter = dom_adapter_1.DomAdapter;
  29354. var dom_renderer_1 = __webpack_require__(188);
  29355. exports.DomRenderer = dom_renderer_1.DomRenderer;
  29356. var dom_tokens_1 = __webpack_require__(187);
  29357. exports.DOCUMENT = dom_tokens_1.DOCUMENT;
  29358. var shared_styles_host_1 = __webpack_require__(196);
  29359. exports.SharedStylesHost = shared_styles_host_1.SharedStylesHost;
  29360. exports.DomSharedStylesHost = shared_styles_host_1.DomSharedStylesHost;
  29361. var dom_events_1 = __webpack_require__(182);
  29362. exports.DomEventsPlugin = dom_events_1.DomEventsPlugin;
  29363. var event_manager_1 = __webpack_require__(183);
  29364. exports.EVENT_MANAGER_PLUGINS = event_manager_1.EVENT_MANAGER_PLUGINS;
  29365. exports.EventManager = event_manager_1.EventManager;
  29366. exports.EventManagerPlugin = event_manager_1.EventManagerPlugin;
  29367. __export(__webpack_require__(204));
  29368. __export(__webpack_require__(205));
  29369. /***/ },
  29370. /* 204 */
  29371. /***/ function(module, exports, __webpack_require__) {
  29372. var lang_1 = __webpack_require__(5);
  29373. var dom_adapter_1 = __webpack_require__(178);
  29374. /**
  29375. * Predicates for use with {@link DebugElement}'s query functions.
  29376. */
  29377. var By = (function () {
  29378. function By() {
  29379. }
  29380. /**
  29381. * Match all elements.
  29382. *
  29383. * ## Example
  29384. *
  29385. * {@example platform/dom/debug/ts/by/by.ts region='by_all'}
  29386. */
  29387. By.all = function () { return function (debugElement) { return true; }; };
  29388. /**
  29389. * Match elements by the given CSS selector.
  29390. *
  29391. * ## Example
  29392. *
  29393. * {@example platform/dom/debug/ts/by/by.ts region='by_css'}
  29394. */
  29395. By.css = function (selector) {
  29396. return function (debugElement) {
  29397. return lang_1.isPresent(debugElement.nativeElement) ?
  29398. dom_adapter_1.DOM.elementMatches(debugElement.nativeElement, selector) :
  29399. false;
  29400. };
  29401. };
  29402. /**
  29403. * Match elements that have the given directive present.
  29404. *
  29405. * ## Example
  29406. *
  29407. * {@example platform/dom/debug/ts/by/by.ts region='by_directive'}
  29408. */
  29409. By.directive = function (type) {
  29410. return function (debugElement) { return debugElement.hasDirective(type); };
  29411. };
  29412. return By;
  29413. })();
  29414. exports.By = By;
  29415. /***/ },
  29416. /* 205 */
  29417. /***/ function(module, exports, __webpack_require__) {
  29418. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  29419. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  29420. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  29421. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  29422. return c > 3 && r && Object.defineProperty(target, key, r), r;
  29423. };
  29424. var __metadata = (this && this.__metadata) || function (k, v) {
  29425. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  29426. };
  29427. var lang_1 = __webpack_require__(5);
  29428. var collection_1 = __webpack_require__(12);
  29429. var di_1 = __webpack_require__(6);
  29430. var view_listener_1 = __webpack_require__(86);
  29431. var dom_adapter_1 = __webpack_require__(178);
  29432. var api_1 = __webpack_require__(72);
  29433. var debug_element_1 = __webpack_require__(101);
  29434. var NG_ID_PROPERTY = 'ngid';
  29435. var INSPECT_GLOBAL_NAME = 'ng.probe';
  29436. var NG_ID_SEPARATOR = '#';
  29437. // Need to keep the views in a global Map so that multiple angular apps are supported
  29438. var _allIdsByView = new collection_1.Map();
  29439. var _allViewsById = new collection_1.Map();
  29440. var _nextId = 0;
  29441. function _setElementId(element, indices) {
  29442. if (lang_1.isPresent(element) && dom_adapter_1.DOM.isElementNode(element)) {
  29443. dom_adapter_1.DOM.setData(element, NG_ID_PROPERTY, indices.join(NG_ID_SEPARATOR));
  29444. }
  29445. }
  29446. function _getElementId(element) {
  29447. var elId = dom_adapter_1.DOM.getData(element, NG_ID_PROPERTY);
  29448. if (lang_1.isPresent(elId)) {
  29449. return elId.split(NG_ID_SEPARATOR).map(function (partStr) { return lang_1.NumberWrapper.parseInt(partStr, 10); });
  29450. }
  29451. else {
  29452. return null;
  29453. }
  29454. }
  29455. /**
  29456. * Returns a {@link DebugElement} for the given native DOM element, or
  29457. * null if the given native element does not have an Angular view associated
  29458. * with it.
  29459. */
  29460. function inspectNativeElement(element) {
  29461. var elId = _getElementId(element);
  29462. if (lang_1.isPresent(elId)) {
  29463. var view = _allViewsById.get(elId[0]);
  29464. if (lang_1.isPresent(view)) {
  29465. return new debug_element_1.DebugElement_(view, elId[1]);
  29466. }
  29467. }
  29468. return null;
  29469. }
  29470. exports.inspectNativeElement = inspectNativeElement;
  29471. var DebugElementViewListener = (function () {
  29472. function DebugElementViewListener(_renderer) {
  29473. this._renderer = _renderer;
  29474. dom_adapter_1.DOM.setGlobalVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
  29475. }
  29476. DebugElementViewListener.prototype.onViewCreated = function (view) {
  29477. var viewId = _nextId++;
  29478. _allViewsById.set(viewId, view);
  29479. _allIdsByView.set(view, viewId);
  29480. for (var i = 0; i < view.elementRefs.length; i++) {
  29481. var el = view.elementRefs[i];
  29482. _setElementId(this._renderer.getNativeElementSync(el), [viewId, i]);
  29483. }
  29484. };
  29485. DebugElementViewListener.prototype.onViewDestroyed = function (view) {
  29486. var viewId = _allIdsByView.get(view);
  29487. _allIdsByView.delete(view);
  29488. _allViewsById.delete(viewId);
  29489. };
  29490. DebugElementViewListener = __decorate([
  29491. di_1.Injectable(),
  29492. __metadata('design:paramtypes', [api_1.Renderer])
  29493. ], DebugElementViewListener);
  29494. return DebugElementViewListener;
  29495. })();
  29496. exports.DebugElementViewListener = DebugElementViewListener;
  29497. /**
  29498. * Providers which support debugging Angular applications (e.g. via `ng.probe`).
  29499. *
  29500. * ## Example
  29501. *
  29502. * {@example platform/dom/debug/ts/debug_element_view_listener/providers.ts region='providers'}
  29503. */
  29504. exports.ELEMENT_PROBE_PROVIDERS = lang_1.CONST_EXPR([
  29505. DebugElementViewListener,
  29506. lang_1.CONST_EXPR(new di_1.Provider(view_listener_1.AppViewListener, { useExisting: DebugElementViewListener })),
  29507. ]);
  29508. /**
  29509. * Use {@link ELEMENT_PROBE_PROVIDERS}.
  29510. *
  29511. * @deprecated
  29512. */
  29513. exports.ELEMENT_PROBE_BINDINGS = exports.ELEMENT_PROBE_PROVIDERS;
  29514. /***/ },
  29515. /* 206 */
  29516. /***/ function(module, exports, __webpack_require__) {
  29517. var lang_1 = __webpack_require__(5);
  29518. var common_tools_1 = __webpack_require__(207);
  29519. var context = lang_1.global;
  29520. /**
  29521. * Enabled Angular 2 debug tools that are accessible via your browser's
  29522. * developer console.
  29523. *
  29524. * Usage:
  29525. *
  29526. * 1. Open developer console (e.g. in Chrome Ctrl + Shift + j)
  29527. * 1. Type `ng.` (usually the console will show auto-complete suggestion)
  29528. * 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
  29529. * then hit Enter.
  29530. */
  29531. function enableDebugTools(ref) {
  29532. context.ng = new common_tools_1.AngularTools(ref);
  29533. }
  29534. exports.enableDebugTools = enableDebugTools;
  29535. /**
  29536. * Disables Angular 2 tools.
  29537. */
  29538. function disableDebugTools() {
  29539. delete context.ng;
  29540. }
  29541. exports.disableDebugTools = disableDebugTools;
  29542. /***/ },
  29543. /* 207 */
  29544. /***/ function(module, exports, __webpack_require__) {
  29545. var application_ref_1 = __webpack_require__(65);
  29546. var lang_1 = __webpack_require__(5);
  29547. var browser_1 = __webpack_require__(208);
  29548. var dom_adapter_1 = __webpack_require__(178);
  29549. /**
  29550. * Entry point for all Angular debug tools. This object corresponds to the `ng`
  29551. * global variable accessible in the dev console.
  29552. */
  29553. var AngularTools = (function () {
  29554. function AngularTools(ref) {
  29555. this.profiler = new AngularProfiler(ref);
  29556. }
  29557. return AngularTools;
  29558. })();
  29559. exports.AngularTools = AngularTools;
  29560. /**
  29561. * Entry point for all Angular profiling-related debug tools. This object
  29562. * corresponds to the `ng.profiler` in the dev console.
  29563. */
  29564. var AngularProfiler = (function () {
  29565. function AngularProfiler(ref) {
  29566. this.appRef = ref.injector.get(application_ref_1.ApplicationRef);
  29567. }
  29568. /**
  29569. * Exercises change detection in a loop and then prints the average amount of
  29570. * time in milliseconds how long a single round of change detection takes for
  29571. * the current state of the UI. It runs a minimum of 5 rounds for a minimum
  29572. * of 500 milliseconds.
  29573. *
  29574. * Optionally, a user may pass a `config` parameter containing a map of
  29575. * options. Supported options are:
  29576. *
  29577. * `record` (boolean) - causes the profiler to record a CPU profile while
  29578. * it exercises the change detector. Example:
  29579. *
  29580. * ```
  29581. * ng.profiler.timeChangeDetection({record: true})
  29582. * ```
  29583. */
  29584. AngularProfiler.prototype.timeChangeDetection = function (config) {
  29585. var record = lang_1.isPresent(config) && config['record'];
  29586. var profileName = 'Change Detection';
  29587. // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened
  29588. var isProfilerAvailable = lang_1.isPresent(browser_1.window.console.profile);
  29589. if (record && isProfilerAvailable) {
  29590. browser_1.window.console.profile(profileName);
  29591. }
  29592. var start = dom_adapter_1.DOM.performanceNow();
  29593. var numTicks = 0;
  29594. while (numTicks < 5 || (dom_adapter_1.DOM.performanceNow() - start) < 500) {
  29595. this.appRef.tick();
  29596. numTicks++;
  29597. }
  29598. var end = dom_adapter_1.DOM.performanceNow();
  29599. if (record && isProfilerAvailable) {
  29600. // need to cast to <any> because type checker thinks there's no argument
  29601. // while in fact there is:
  29602. //
  29603. // https://developer.mozilla.org/en-US/docs/Web/API/Console/profileEnd
  29604. browser_1.window.console.profileEnd(profileName);
  29605. }
  29606. var msPerTick = (end - start) / numTicks;
  29607. browser_1.window.console.log("ran " + numTicks + " change detection cycles");
  29608. browser_1.window.console.log(lang_1.NumberWrapper.toFixed(msPerTick, 2) + " ms per check");
  29609. };
  29610. return AngularProfiler;
  29611. })();
  29612. exports.AngularProfiler = AngularProfiler;
  29613. /***/ },
  29614. /* 208 */
  29615. /***/ function(module, exports) {
  29616. /**
  29617. * JS version of browser APIs. This library can only run in the browser.
  29618. */
  29619. var win = window;
  29620. exports.window = win;
  29621. exports.document = window.document;
  29622. exports.location = window.location;
  29623. exports.gc = window['gc'] ? function () { return window['gc'](); } : function () { return null; };
  29624. exports.performance = window['performance'] ? window['performance'] : null;
  29625. exports.Event = window['Event'];
  29626. exports.MouseEvent = window['MouseEvent'];
  29627. exports.KeyboardEvent = window['KeyboardEvent'];
  29628. exports.EventTarget = window['EventTarget'];
  29629. exports.History = window['History'];
  29630. exports.Location = window['Location'];
  29631. exports.EventListener = window['EventListener'];
  29632. /***/ },
  29633. /* 209 */
  29634. /***/ function(module, exports, __webpack_require__) {
  29635. /**
  29636. * @module
  29637. * @description
  29638. * The http module provides services to perform http requests. To get started, see the {@link Http}
  29639. * class.
  29640. */
  29641. var core_1 = __webpack_require__(2);
  29642. var http_1 = __webpack_require__(210);
  29643. var xhr_backend_1 = __webpack_require__(218);
  29644. var jsonp_backend_1 = __webpack_require__(222);
  29645. var browser_xhr_1 = __webpack_require__(221);
  29646. var browser_jsonp_1 = __webpack_require__(223);
  29647. var base_request_options_1 = __webpack_require__(216);
  29648. var base_response_options_1 = __webpack_require__(220);
  29649. var static_request_1 = __webpack_require__(212);
  29650. exports.Request = static_request_1.Request;
  29651. var static_response_1 = __webpack_require__(219);
  29652. exports.Response = static_response_1.Response;
  29653. var interfaces_1 = __webpack_require__(211);
  29654. exports.Connection = interfaces_1.Connection;
  29655. exports.ConnectionBackend = interfaces_1.ConnectionBackend;
  29656. var browser_xhr_2 = __webpack_require__(221);
  29657. exports.BrowserXhr = browser_xhr_2.BrowserXhr;
  29658. var base_request_options_2 = __webpack_require__(216);
  29659. exports.BaseRequestOptions = base_request_options_2.BaseRequestOptions;
  29660. exports.RequestOptions = base_request_options_2.RequestOptions;
  29661. var base_response_options_2 = __webpack_require__(220);
  29662. exports.BaseResponseOptions = base_response_options_2.BaseResponseOptions;
  29663. exports.ResponseOptions = base_response_options_2.ResponseOptions;
  29664. var xhr_backend_2 = __webpack_require__(218);
  29665. exports.XHRBackend = xhr_backend_2.XHRBackend;
  29666. exports.XHRConnection = xhr_backend_2.XHRConnection;
  29667. var jsonp_backend_2 = __webpack_require__(222);
  29668. exports.JSONPBackend = jsonp_backend_2.JSONPBackend;
  29669. exports.JSONPConnection = jsonp_backend_2.JSONPConnection;
  29670. var http_2 = __webpack_require__(210);
  29671. exports.Http = http_2.Http;
  29672. exports.Jsonp = http_2.Jsonp;
  29673. var headers_1 = __webpack_require__(213);
  29674. exports.Headers = headers_1.Headers;
  29675. var enums_1 = __webpack_require__(215);
  29676. exports.ResponseType = enums_1.ResponseType;
  29677. exports.ReadyState = enums_1.ReadyState;
  29678. exports.RequestMethod = enums_1.RequestMethod;
  29679. var url_search_params_1 = __webpack_require__(217);
  29680. exports.URLSearchParams = url_search_params_1.URLSearchParams;
  29681. /**
  29682. * Provides a basic set of injectables to use the {@link Http} service in any application.
  29683. *
  29684. * The `HTTP_PROVIDERS` should be included either in a component's injector,
  29685. * or in the root injector when bootstrapping an application.
  29686. *
  29687. * ### Example ([live demo](http://plnkr.co/edit/snj7Nv?p=preview))
  29688. *
  29689. * ```
  29690. * import {Component} from 'angular2/core';
  29691. * import {bootstrap} from 'angular2/platform/browser';
  29692. * import {NgFor} from 'angular2/common';
  29693. * import {HTTP_PROVIDERS, Http} from 'angular2/http';
  29694. *
  29695. * @Component({
  29696. * selector: 'app',
  29697. * providers: [HTTP_PROVIDERS],
  29698. * template: `
  29699. * <div>
  29700. * <h1>People</h1>
  29701. * <ul>
  29702. * <li *ngFor="#person of people">
  29703. * {{person.name}}
  29704. * </li>
  29705. * </ul>
  29706. * </div>
  29707. * `,
  29708. * directives: [NgFor]
  29709. * })
  29710. * export class App {
  29711. * people: Object[];
  29712. * constructor(http:Http) {
  29713. * http.get('people.json').subscribe(res => {
  29714. * this.people = res.json();
  29715. * });
  29716. * }
  29717. * active:boolean = false;
  29718. * toggleActiveState() {
  29719. * this.active = !this.active;
  29720. * }
  29721. * }
  29722. *
  29723. * bootstrap(App)
  29724. * .catch(err => console.error(err));
  29725. * ```
  29726. *
  29727. * The primary public API included in `HTTP_PROVIDERS` is the {@link Http} class.
  29728. * However, other providers required by `Http` are included,
  29729. * which may be beneficial to override in certain cases.
  29730. *
  29731. * The providers included in `HTTP_PROVIDERS` include:
  29732. * * {@link Http}
  29733. * * {@link XHRBackend}
  29734. * * `BrowserXHR` - Private factory to create `XMLHttpRequest` instances
  29735. * * {@link RequestOptions} - Bound to {@link BaseRequestOptions} class
  29736. * * {@link ResponseOptions} - Bound to {@link BaseResponseOptions} class
  29737. *
  29738. * There may be cases where it makes sense to extend the base request options,
  29739. * such as to add a search string to be appended to all URLs.
  29740. * To accomplish this, a new provider for {@link RequestOptions} should
  29741. * be added in the same injector as `HTTP_PROVIDERS`.
  29742. *
  29743. * ### Example ([live demo](http://plnkr.co/edit/aCMEXi?p=preview))
  29744. *
  29745. * ```
  29746. * import {provide} from 'angular2/core';
  29747. * import {bootstrap} from 'angular2/platform/browser';
  29748. * import {HTTP_PROVIDERS, BaseRequestOptions, RequestOptions} from 'angular2/http';
  29749. *
  29750. * class MyOptions extends BaseRequestOptions {
  29751. * search: string = 'coreTeam=true';
  29752. * }
  29753. *
  29754. * bootstrap(App, [HTTP_PROVIDERS, provide(RequestOptions, {useClass: MyOptions})])
  29755. * .catch(err => console.error(err));
  29756. * ```
  29757. *
  29758. * Likewise, to use a mock backend for unit tests, the {@link XHRBackend}
  29759. * provider should be bound to {@link MockBackend}.
  29760. *
  29761. * ### Example ([live demo](http://plnkr.co/edit/7LWALD?p=preview))
  29762. *
  29763. * ```
  29764. * import {provide} from 'angular2/core';
  29765. * import {bootstrap} from 'angular2/platform/browser';
  29766. * import {HTTP_PROVIDERS, Http, Response, XHRBackend} from 'angular2/http';
  29767. * import {MockBackend} from 'angular2/http/testing';
  29768. *
  29769. * var people = [{name: 'Jeff'}, {name: 'Tobias'}];
  29770. *
  29771. * var injector = Injector.resolveAndCreate([
  29772. * HTTP_PROVIDERS,
  29773. * MockBackend,
  29774. * provide(XHRBackend, {useExisting: MockBackend})
  29775. * ]);
  29776. * var http = injector.get(Http);
  29777. * var backend = injector.get(MockBackend);
  29778. *
  29779. * // Listen for any new requests
  29780. * backend.connections.observer({
  29781. * next: connection => {
  29782. * var response = new Response({body: people});
  29783. * setTimeout(() => {
  29784. * // Send a response to the request
  29785. * connection.mockRespond(response);
  29786. * });
  29787. * });
  29788. *
  29789. * http.get('people.json').observer({
  29790. * next: res => {
  29791. * // Response came from mock backend
  29792. * console.log('first person', res.json()[0].name);
  29793. * }
  29794. * });
  29795. * ```
  29796. */
  29797. exports.HTTP_PROVIDERS = [
  29798. // TODO(pascal): use factory type annotations once supported in DI
  29799. // issue: https://github.com/angular/angular/issues/3183
  29800. core_1.provide(http_1.Http, {
  29801. useFactory: function (xhrBackend, requestOptions) { return new http_1.Http(xhrBackend, requestOptions); },
  29802. deps: [xhr_backend_1.XHRBackend, base_request_options_1.RequestOptions]
  29803. }),
  29804. browser_xhr_1.BrowserXhr,
  29805. core_1.provide(base_request_options_1.RequestOptions, { useClass: base_request_options_1.BaseRequestOptions }),
  29806. core_1.provide(base_response_options_1.ResponseOptions, { useClass: base_response_options_1.BaseResponseOptions }),
  29807. xhr_backend_1.XHRBackend
  29808. ];
  29809. /**
  29810. * See {@link HTTP_PROVIDERS} instead.
  29811. *
  29812. * @deprecated
  29813. */
  29814. exports.HTTP_BINDINGS = exports.HTTP_PROVIDERS;
  29815. /**
  29816. * Provides a basic set of providers to use the {@link Jsonp} service in any application.
  29817. *
  29818. * The `JSONP_PROVIDERS` should be included either in a component's injector,
  29819. * or in the root injector when bootstrapping an application.
  29820. *
  29821. * ### Example ([live demo](http://plnkr.co/edit/vmeN4F?p=preview))
  29822. *
  29823. * ```
  29824. * import {Component} from 'angular2/core';
  29825. * import {NgFor} from 'angular2/common';
  29826. * import {JSONP_PROVIDERS, Jsonp} from 'angular2/http';
  29827. *
  29828. * @Component({
  29829. * selector: 'app',
  29830. * providers: [JSONP_PROVIDERS],
  29831. * template: `
  29832. * <div>
  29833. * <h1>People</h1>
  29834. * <ul>
  29835. * <li *ngFor="#person of people">
  29836. * {{person.name}}
  29837. * </li>
  29838. * </ul>
  29839. * </div>
  29840. * `,
  29841. * directives: [NgFor]
  29842. * })
  29843. * export class App {
  29844. * people: Array<Object>;
  29845. * constructor(jsonp:Jsonp) {
  29846. * jsonp.request('people.json').subscribe(res => {
  29847. * this.people = res.json();
  29848. * })
  29849. * }
  29850. * }
  29851. * ```
  29852. *
  29853. * The primary public API included in `JSONP_PROVIDERS` is the {@link Jsonp} class.
  29854. * However, other providers required by `Jsonp` are included,
  29855. * which may be beneficial to override in certain cases.
  29856. *
  29857. * The providers included in `JSONP_PROVIDERS` include:
  29858. * * {@link Jsonp}
  29859. * * {@link JSONPBackend}
  29860. * * `BrowserJsonp` - Private factory
  29861. * * {@link RequestOptions} - Bound to {@link BaseRequestOptions} class
  29862. * * {@link ResponseOptions} - Bound to {@link BaseResponseOptions} class
  29863. *
  29864. * There may be cases where it makes sense to extend the base request options,
  29865. * such as to add a search string to be appended to all URLs.
  29866. * To accomplish this, a new provider for {@link RequestOptions} should
  29867. * be added in the same injector as `JSONP_PROVIDERS`.
  29868. *
  29869. * ### Example ([live demo](http://plnkr.co/edit/TFug7x?p=preview))
  29870. *
  29871. * ```
  29872. * import {provide} from 'angular2/core';
  29873. * import {bootstrap} from 'angular2/platform/browser';
  29874. * import {JSONP_PROVIDERS, BaseRequestOptions, RequestOptions} from 'angular2/http';
  29875. *
  29876. * class MyOptions extends BaseRequestOptions {
  29877. * search: string = 'coreTeam=true';
  29878. * }
  29879. *
  29880. * bootstrap(App, [JSONP_PROVIDERS, provide(RequestOptions, {useClass: MyOptions})])
  29881. * .catch(err => console.error(err));
  29882. * ```
  29883. *
  29884. * Likewise, to use a mock backend for unit tests, the {@link JSONPBackend}
  29885. * provider should be bound to {@link MockBackend}.
  29886. *
  29887. * ### Example ([live demo](http://plnkr.co/edit/HDqZWL?p=preview))
  29888. *
  29889. * ```
  29890. * import {provide, Injector} from 'angular2/core';
  29891. * import {JSONP_PROVIDERS, Jsonp, Response, JSONPBackend} from 'angular2/http';
  29892. * import {MockBackend} from 'angular2/http/testing';
  29893. *
  29894. * var people = [{name: 'Jeff'}, {name: 'Tobias'}];
  29895. * var injector = Injector.resolveAndCreate([
  29896. * JSONP_PROVIDERS,
  29897. * MockBackend,
  29898. * provide(JSONPBackend, {useExisting: MockBackend})
  29899. * ]);
  29900. * var jsonp = injector.get(Jsonp);
  29901. * var backend = injector.get(MockBackend);
  29902. *
  29903. * // Listen for any new requests
  29904. * backend.connections.observer({
  29905. * next: connection => {
  29906. * var response = new Response({body: people});
  29907. * setTimeout(() => {
  29908. * // Send a response to the request
  29909. * connection.mockRespond(response);
  29910. * });
  29911. * });
  29912. * jsonp.get('people.json').observer({
  29913. * next: res => {
  29914. * // Response came from mock backend
  29915. * console.log('first person', res.json()[0].name);
  29916. * }
  29917. * });
  29918. * ```
  29919. */
  29920. exports.JSONP_PROVIDERS = [
  29921. // TODO(pascal): use factory type annotations once supported in DI
  29922. // issue: https://github.com/angular/angular/issues/3183
  29923. core_1.provide(http_1.Jsonp, {
  29924. useFactory: function (jsonpBackend, requestOptions) { return new http_1.Jsonp(jsonpBackend, requestOptions); },
  29925. deps: [jsonp_backend_1.JSONPBackend, base_request_options_1.RequestOptions]
  29926. }),
  29927. browser_jsonp_1.BrowserJsonp,
  29928. core_1.provide(base_request_options_1.RequestOptions, { useClass: base_request_options_1.BaseRequestOptions }),
  29929. core_1.provide(base_response_options_1.ResponseOptions, { useClass: base_response_options_1.BaseResponseOptions }),
  29930. core_1.provide(jsonp_backend_1.JSONPBackend, { useClass: jsonp_backend_1.JSONPBackend_ })
  29931. ];
  29932. /**
  29933. * See {@link JSONP_PROVIDERS} instead.
  29934. *
  29935. * @deprecated
  29936. */
  29937. exports.JSON_BINDINGS = exports.JSONP_PROVIDERS;
  29938. /***/ },
  29939. /* 210 */
  29940. /***/ function(module, exports, __webpack_require__) {
  29941. var __extends = (this && this.__extends) || function (d, b) {
  29942. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  29943. function __() { this.constructor = d; }
  29944. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29945. };
  29946. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  29947. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  29948. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  29949. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  29950. return c > 3 && r && Object.defineProperty(target, key, r), r;
  29951. };
  29952. var __metadata = (this && this.__metadata) || function (k, v) {
  29953. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  29954. };
  29955. var lang_1 = __webpack_require__(5);
  29956. var exceptions_1 = __webpack_require__(14);
  29957. var core_1 = __webpack_require__(2);
  29958. var interfaces_1 = __webpack_require__(211);
  29959. var static_request_1 = __webpack_require__(212);
  29960. var base_request_options_1 = __webpack_require__(216);
  29961. var enums_1 = __webpack_require__(215);
  29962. function httpRequest(backend, request) {
  29963. return backend.createConnection(request).response;
  29964. }
  29965. function mergeOptions(defaultOpts, providedOpts, method, url) {
  29966. var newOptions = defaultOpts;
  29967. if (lang_1.isPresent(providedOpts)) {
  29968. // Hack so Dart can used named parameters
  29969. return newOptions.merge(new base_request_options_1.RequestOptions({
  29970. method: providedOpts.method || method,
  29971. url: providedOpts.url || url,
  29972. search: providedOpts.search,
  29973. headers: providedOpts.headers,
  29974. body: providedOpts.body
  29975. }));
  29976. }
  29977. if (lang_1.isPresent(method)) {
  29978. return newOptions.merge(new base_request_options_1.RequestOptions({ method: method, url: url }));
  29979. }
  29980. else {
  29981. return newOptions.merge(new base_request_options_1.RequestOptions({ url: url }));
  29982. }
  29983. }
  29984. /**
  29985. * Performs http requests using `XMLHttpRequest` as the default backend.
  29986. *
  29987. * `Http` is available as an injectable class, with methods to perform http requests. Calling
  29988. * `request` returns an `Observable` which will emit a single {@link Response} when a
  29989. * response is received.
  29990. *
  29991. * ### Example
  29992. *
  29993. * ```typescript
  29994. * import {Http, HTTP_PROVIDERS} from 'angular2/http';
  29995. * @Component({
  29996. * selector: 'http-app',
  29997. * viewProviders: [HTTP_PROVIDERS],
  29998. * templateUrl: 'people.html'
  29999. * })
  30000. * class PeopleComponent {
  30001. * constructor(http: Http) {
  30002. * http.get('people.json')
  30003. * // Call map on the response observable to get the parsed people object
  30004. * .map(res => res.json())
  30005. * // Subscribe to the observable to get the parsed people object and attach it to the
  30006. * // component
  30007. * .subscribe(people => this.people = people);
  30008. * }
  30009. * }
  30010. * ```
  30011. *
  30012. *
  30013. * ### Example
  30014. *
  30015. * ```
  30016. * http.get('people.json').observer({next: (value) => this.people = value});
  30017. * ```
  30018. *
  30019. * The default construct used to perform requests, `XMLHttpRequest`, is abstracted as a "Backend" (
  30020. * {@link XHRBackend} in this case), which could be mocked with dependency injection by replacing
  30021. * the {@link XHRBackend} provider, as in the following example:
  30022. *
  30023. * ### Example
  30024. *
  30025. * ```typescript
  30026. * import {BaseRequestOptions, Http} from 'angular2/http';
  30027. * import {MockBackend} from 'angular2/http/testing';
  30028. * var injector = Injector.resolveAndCreate([
  30029. * BaseRequestOptions,
  30030. * MockBackend,
  30031. * provide(Http, {useFactory:
  30032. * function(backend, defaultOptions) {
  30033. * return new Http(backend, defaultOptions);
  30034. * },
  30035. * deps: [MockBackend, BaseRequestOptions]})
  30036. * ]);
  30037. * var http = injector.get(Http);
  30038. * http.get('request-from-mock-backend.json').subscribe((res:Response) => doSomething(res));
  30039. * ```
  30040. *
  30041. **/
  30042. var Http = (function () {
  30043. function Http(_backend, _defaultOptions) {
  30044. this._backend = _backend;
  30045. this._defaultOptions = _defaultOptions;
  30046. }
  30047. /**
  30048. * Performs any type of http request. First argument is required, and can either be a url or
  30049. * a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions}
  30050. * object can be provided as the 2nd argument. The options object will be merged with the values
  30051. * of {@link BaseRequestOptions} before performing the request.
  30052. */
  30053. Http.prototype.request = function (url, options) {
  30054. var responseObservable;
  30055. if (lang_1.isString(url)) {
  30056. responseObservable = httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions, options, enums_1.RequestMethod.Get, url)));
  30057. }
  30058. else if (url instanceof static_request_1.Request) {
  30059. responseObservable = httpRequest(this._backend, url);
  30060. }
  30061. else {
  30062. throw exceptions_1.makeTypeError('First argument must be a url string or Request instance.');
  30063. }
  30064. return responseObservable;
  30065. };
  30066. /**
  30067. * Performs a request with `get` http method.
  30068. */
  30069. Http.prototype.get = function (url, options) {
  30070. return httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions, options, enums_1.RequestMethod.Get, url)));
  30071. };
  30072. /**
  30073. * Performs a request with `post` http method.
  30074. */
  30075. Http.prototype.post = function (url, body, options) {
  30076. return httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions.merge(new base_request_options_1.RequestOptions({ body: body })), options, enums_1.RequestMethod.Post, url)));
  30077. };
  30078. /**
  30079. * Performs a request with `put` http method.
  30080. */
  30081. Http.prototype.put = function (url, body, options) {
  30082. return httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions.merge(new base_request_options_1.RequestOptions({ body: body })), options, enums_1.RequestMethod.Put, url)));
  30083. };
  30084. /**
  30085. * Performs a request with `delete` http method.
  30086. */
  30087. Http.prototype.delete = function (url, options) {
  30088. return httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions, options, enums_1.RequestMethod.Delete, url)));
  30089. };
  30090. /**
  30091. * Performs a request with `patch` http method.
  30092. */
  30093. Http.prototype.patch = function (url, body, options) {
  30094. return httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions.merge(new base_request_options_1.RequestOptions({ body: body })), options, enums_1.RequestMethod.Patch, url)));
  30095. };
  30096. /**
  30097. * Performs a request with `head` http method.
  30098. */
  30099. Http.prototype.head = function (url, options) {
  30100. return httpRequest(this._backend, new static_request_1.Request(mergeOptions(this._defaultOptions, options, enums_1.RequestMethod.Head, url)));
  30101. };
  30102. Http = __decorate([
  30103. core_1.Injectable(),
  30104. __metadata('design:paramtypes', [interfaces_1.ConnectionBackend, base_request_options_1.RequestOptions])
  30105. ], Http);
  30106. return Http;
  30107. })();
  30108. exports.Http = Http;
  30109. var Jsonp = (function (_super) {
  30110. __extends(Jsonp, _super);
  30111. function Jsonp(backend, defaultOptions) {
  30112. _super.call(this, backend, defaultOptions);
  30113. }
  30114. /**
  30115. * Performs any type of http request. First argument is required, and can either be a url or
  30116. * a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions}
  30117. * object can be provided as the 2nd argument. The options object will be merged with the values
  30118. * of {@link BaseRequestOptions} before performing the request.
  30119. */
  30120. Jsonp.prototype.request = function (url, options) {
  30121. var responseObservable;
  30122. if (lang_1.isString(url)) {
  30123. url = new static_request_1.Request(mergeOptions(this._defaultOptions, options, enums_1.RequestMethod.Get, url));
  30124. }
  30125. if (url instanceof static_request_1.Request) {
  30126. if (url.method !== enums_1.RequestMethod.Get) {
  30127. exceptions_1.makeTypeError('JSONP requests must use GET request method.');
  30128. }
  30129. responseObservable = httpRequest(this._backend, url);
  30130. }
  30131. else {
  30132. throw exceptions_1.makeTypeError('First argument must be a url string or Request instance.');
  30133. }
  30134. return responseObservable;
  30135. };
  30136. Jsonp = __decorate([
  30137. core_1.Injectable(),
  30138. __metadata('design:paramtypes', [interfaces_1.ConnectionBackend, base_request_options_1.RequestOptions])
  30139. ], Jsonp);
  30140. return Jsonp;
  30141. })(Http);
  30142. exports.Jsonp = Jsonp;
  30143. /***/ },
  30144. /* 211 */
  30145. /***/ function(module, exports) {
  30146. /**
  30147. * Abstract class from which real backends are derived.
  30148. *
  30149. * The primary purpose of a `ConnectionBackend` is to create new connections to fulfill a given
  30150. * {@link Request}.
  30151. */
  30152. var ConnectionBackend = (function () {
  30153. function ConnectionBackend() {
  30154. }
  30155. return ConnectionBackend;
  30156. })();
  30157. exports.ConnectionBackend = ConnectionBackend;
  30158. /**
  30159. * Abstract class from which real connections are derived.
  30160. */
  30161. var Connection = (function () {
  30162. function Connection() {
  30163. }
  30164. return Connection;
  30165. })();
  30166. exports.Connection = Connection;
  30167. /***/ },
  30168. /* 212 */
  30169. /***/ function(module, exports, __webpack_require__) {
  30170. var headers_1 = __webpack_require__(213);
  30171. var http_utils_1 = __webpack_require__(214);
  30172. var lang_1 = __webpack_require__(5);
  30173. // TODO(jeffbcross): properly implement body accessors
  30174. /**
  30175. * Creates `Request` instances from provided values.
  30176. *
  30177. * The Request's interface is inspired by the Request constructor defined in the [Fetch
  30178. * Spec](https://fetch.spec.whatwg.org/#request-class),
  30179. * but is considered a static value whose body can be accessed many times. There are other
  30180. * differences in the implementation, but this is the most significant.
  30181. *
  30182. * `Request` instances are typically created by higher-level classes, like {@link Http} and
  30183. * {@link Jsonp}, but it may occasionally be useful to explicitly create `Request` instances.
  30184. * One such example is when creating services that wrap higher-level services, like {@link Http},
  30185. * where it may be useful to generate a `Request` with arbitrary headers and search params.
  30186. *
  30187. * ```typescript
  30188. * import {Injectable, Injector} from 'angular2/core';
  30189. * import {HTTP_PROVIDERS, Http, Request, RequestMethod} from 'angular2/http';
  30190. *
  30191. * @Injectable()
  30192. * class AutoAuthenticator {
  30193. * constructor(public http:Http) {}
  30194. * request(url:string) {
  30195. * return this.http.request(new Request({
  30196. * method: RequestMethod.Get,
  30197. * url: url,
  30198. * search: 'password=123'
  30199. * }));
  30200. * }
  30201. * }
  30202. *
  30203. * var injector = Injector.resolveAndCreate([HTTP_PROVIDERS, AutoAuthenticator]);
  30204. * var authenticator = injector.get(AutoAuthenticator);
  30205. * authenticator.request('people.json').subscribe(res => {
  30206. * //URL should have included '?password=123'
  30207. * console.log('people', res.json());
  30208. * });
  30209. * ```
  30210. */
  30211. var Request = (function () {
  30212. function Request(requestOptions) {
  30213. // TODO: assert that url is present
  30214. var url = requestOptions.url;
  30215. this.url = requestOptions.url;
  30216. if (lang_1.isPresent(requestOptions.search)) {
  30217. var search = requestOptions.search.toString();
  30218. if (search.length > 0) {
  30219. var prefix = '?';
  30220. if (lang_1.StringWrapper.contains(this.url, '?')) {
  30221. prefix = (this.url[this.url.length - 1] == '&') ? '' : '&';
  30222. }
  30223. // TODO: just delete search-query-looking string in url?
  30224. this.url = url + prefix + search;
  30225. }
  30226. }
  30227. this._body = requestOptions.body;
  30228. this.method = http_utils_1.normalizeMethodName(requestOptions.method);
  30229. // TODO(jeffbcross): implement behavior
  30230. // Defaults to 'omit', consistent with browser
  30231. // TODO(jeffbcross): implement behavior
  30232. this.headers = new headers_1.Headers(requestOptions.headers);
  30233. }
  30234. /**
  30235. * Returns the request's body as string, assuming that body exists. If body is undefined, return
  30236. * empty
  30237. * string.
  30238. */
  30239. Request.prototype.text = function () { return lang_1.isPresent(this._body) ? this._body.toString() : ''; };
  30240. return Request;
  30241. })();
  30242. exports.Request = Request;
  30243. /***/ },
  30244. /* 213 */
  30245. /***/ function(module, exports, __webpack_require__) {
  30246. var lang_1 = __webpack_require__(5);
  30247. var exceptions_1 = __webpack_require__(14);
  30248. var collection_1 = __webpack_require__(12);
  30249. /**
  30250. * Polyfill for [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers), as
  30251. * specified in the [Fetch Spec](https://fetch.spec.whatwg.org/#headers-class).
  30252. *
  30253. * The only known difference between this `Headers` implementation and the spec is the
  30254. * lack of an `entries` method.
  30255. *
  30256. * ### Example ([live demo](http://plnkr.co/edit/MTdwT6?p=preview))
  30257. *
  30258. * ```
  30259. * import {Headers} from 'angular2/http';
  30260. *
  30261. * var firstHeaders = new Headers();
  30262. * firstHeaders.append('Content-Type', 'image/jpeg');
  30263. * console.log(firstHeaders.get('Content-Type')) //'image/jpeg'
  30264. *
  30265. * // Create headers from Plain Old JavaScript Object
  30266. * var secondHeaders = new Headers({
  30267. * 'X-My-Custom-Header': 'Angular'
  30268. * });
  30269. * console.log(secondHeaders.get('X-My-Custom-Header')); //'Angular'
  30270. *
  30271. * var thirdHeaders = new Headers(secondHeaders);
  30272. * console.log(thirdHeaders.get('X-My-Custom-Header')); //'Angular'
  30273. * ```
  30274. */
  30275. var Headers = (function () {
  30276. function Headers(headers) {
  30277. var _this = this;
  30278. if (headers instanceof Headers) {
  30279. this._headersMap = headers._headersMap;
  30280. return;
  30281. }
  30282. this._headersMap = new collection_1.Map();
  30283. if (lang_1.isBlank(headers)) {
  30284. return;
  30285. }
  30286. // headers instanceof StringMap
  30287. collection_1.StringMapWrapper.forEach(headers, function (v, k) { _this._headersMap.set(k, collection_1.isListLikeIterable(v) ? v : [v]); });
  30288. }
  30289. /**
  30290. * Returns a new Headers instance from the given DOMString of Response Headers
  30291. */
  30292. Headers.fromResponseHeaderString = function (headersString) {
  30293. return headersString.trim()
  30294. .split('\n')
  30295. .map(function (val) { return val.split(':'); })
  30296. .map(function (_a) {
  30297. var key = _a[0], parts = _a.slice(1);
  30298. return ([key.trim(), parts.join(':').trim()]);
  30299. })
  30300. .reduce(function (headers, _a) {
  30301. var key = _a[0], value = _a[1];
  30302. return !headers.set(key, value) && headers;
  30303. }, new Headers());
  30304. };
  30305. /**
  30306. * Appends a header to existing list of header values for a given header name.
  30307. */
  30308. Headers.prototype.append = function (name, value) {
  30309. var mapName = this._headersMap.get(name);
  30310. var list = collection_1.isListLikeIterable(mapName) ? mapName : [];
  30311. list.push(value);
  30312. this._headersMap.set(name, list);
  30313. };
  30314. /**
  30315. * Deletes all header values for the given name.
  30316. */
  30317. Headers.prototype.delete = function (name) { this._headersMap.delete(name); };
  30318. Headers.prototype.forEach = function (fn) {
  30319. this._headersMap.forEach(fn);
  30320. };
  30321. /**
  30322. * Returns first header that matches given name.
  30323. */
  30324. Headers.prototype.get = function (header) { return collection_1.ListWrapper.first(this._headersMap.get(header)); };
  30325. /**
  30326. * Check for existence of header by given name.
  30327. */
  30328. Headers.prototype.has = function (header) { return this._headersMap.has(header); };
  30329. /**
  30330. * Provides names of set headers
  30331. */
  30332. Headers.prototype.keys = function () { return collection_1.MapWrapper.keys(this._headersMap); };
  30333. /**
  30334. * Sets or overrides header value for given name.
  30335. */
  30336. Headers.prototype.set = function (header, value) {
  30337. var list = [];
  30338. if (collection_1.isListLikeIterable(value)) {
  30339. var pushValue = value.join(',');
  30340. list.push(pushValue);
  30341. }
  30342. else {
  30343. list.push(value);
  30344. }
  30345. this._headersMap.set(header, list);
  30346. };
  30347. /**
  30348. * Returns values of all headers.
  30349. */
  30350. Headers.prototype.values = function () { return collection_1.MapWrapper.values(this._headersMap); };
  30351. /**
  30352. * Returns string of all headers.
  30353. */
  30354. Headers.prototype.toJSON = function () { return lang_1.Json.stringify(this.values()); };
  30355. /**
  30356. * Returns list of header values for a given name.
  30357. */
  30358. Headers.prototype.getAll = function (header) {
  30359. var headers = this._headersMap.get(header);
  30360. return collection_1.isListLikeIterable(headers) ? headers : [];
  30361. };
  30362. /**
  30363. * This method is not implemented.
  30364. */
  30365. Headers.prototype.entries = function () { throw new exceptions_1.BaseException('"entries" method is not implemented on Headers class'); };
  30366. return Headers;
  30367. })();
  30368. exports.Headers = Headers;
  30369. /***/ },
  30370. /* 214 */
  30371. /***/ function(module, exports, __webpack_require__) {
  30372. var lang_1 = __webpack_require__(5);
  30373. var enums_1 = __webpack_require__(215);
  30374. var exceptions_1 = __webpack_require__(14);
  30375. function normalizeMethodName(method) {
  30376. if (lang_1.isString(method)) {
  30377. var originalMethod = method;
  30378. method = method.replace(/(\w)(\w*)/g, function (g0, g1, g2) { return g1.toUpperCase() + g2.toLowerCase(); });
  30379. method = enums_1.RequestMethod[method];
  30380. if (typeof method !== 'number')
  30381. throw exceptions_1.makeTypeError("Invalid request method. The method \"" + originalMethod + "\" is not supported.");
  30382. }
  30383. return method;
  30384. }
  30385. exports.normalizeMethodName = normalizeMethodName;
  30386. exports.isSuccess = function (status) { return (status >= 200 && status < 300); };
  30387. function getResponseURL(xhr) {
  30388. if ('responseURL' in xhr) {
  30389. return xhr.responseURL;
  30390. }
  30391. if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) {
  30392. return xhr.getResponseHeader('X-Request-URL');
  30393. }
  30394. return;
  30395. }
  30396. exports.getResponseURL = getResponseURL;
  30397. var lang_2 = __webpack_require__(5);
  30398. exports.isJsObject = lang_2.isJsObject;
  30399. /***/ },
  30400. /* 215 */
  30401. /***/ function(module, exports) {
  30402. /**
  30403. * Supported http methods.
  30404. */
  30405. (function (RequestMethod) {
  30406. RequestMethod[RequestMethod["Get"] = 0] = "Get";
  30407. RequestMethod[RequestMethod["Post"] = 1] = "Post";
  30408. RequestMethod[RequestMethod["Put"] = 2] = "Put";
  30409. RequestMethod[RequestMethod["Delete"] = 3] = "Delete";
  30410. RequestMethod[RequestMethod["Options"] = 4] = "Options";
  30411. RequestMethod[RequestMethod["Head"] = 5] = "Head";
  30412. RequestMethod[RequestMethod["Patch"] = 6] = "Patch";
  30413. })(exports.RequestMethod || (exports.RequestMethod = {}));
  30414. var RequestMethod = exports.RequestMethod;
  30415. /**
  30416. * All possible states in which a connection can be, based on
  30417. * [States](http://www.w3.org/TR/XMLHttpRequest/#states) from the `XMLHttpRequest` spec, but with an
  30418. * additional "CANCELLED" state.
  30419. */
  30420. (function (ReadyState) {
  30421. ReadyState[ReadyState["Unsent"] = 0] = "Unsent";
  30422. ReadyState[ReadyState["Open"] = 1] = "Open";
  30423. ReadyState[ReadyState["HeadersReceived"] = 2] = "HeadersReceived";
  30424. ReadyState[ReadyState["Loading"] = 3] = "Loading";
  30425. ReadyState[ReadyState["Done"] = 4] = "Done";
  30426. ReadyState[ReadyState["Cancelled"] = 5] = "Cancelled";
  30427. })(exports.ReadyState || (exports.ReadyState = {}));
  30428. var ReadyState = exports.ReadyState;
  30429. /**
  30430. * Acceptable response types to be associated with a {@link Response}, based on
  30431. * [ResponseType](https://fetch.spec.whatwg.org/#responsetype) from the Fetch spec.
  30432. */
  30433. (function (ResponseType) {
  30434. ResponseType[ResponseType["Basic"] = 0] = "Basic";
  30435. ResponseType[ResponseType["Cors"] = 1] = "Cors";
  30436. ResponseType[ResponseType["Default"] = 2] = "Default";
  30437. ResponseType[ResponseType["Error"] = 3] = "Error";
  30438. ResponseType[ResponseType["Opaque"] = 4] = "Opaque";
  30439. })(exports.ResponseType || (exports.ResponseType = {}));
  30440. var ResponseType = exports.ResponseType;
  30441. /***/ },
  30442. /* 216 */
  30443. /***/ function(module, exports, __webpack_require__) {
  30444. var __extends = (this && this.__extends) || function (d, b) {
  30445. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  30446. function __() { this.constructor = d; }
  30447. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30448. };
  30449. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  30450. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  30451. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  30452. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  30453. return c > 3 && r && Object.defineProperty(target, key, r), r;
  30454. };
  30455. var __metadata = (this && this.__metadata) || function (k, v) {
  30456. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  30457. };
  30458. var lang_1 = __webpack_require__(5);
  30459. var headers_1 = __webpack_require__(213);
  30460. var enums_1 = __webpack_require__(215);
  30461. var core_1 = __webpack_require__(2);
  30462. var url_search_params_1 = __webpack_require__(217);
  30463. var http_utils_1 = __webpack_require__(214);
  30464. /**
  30465. * Creates a request options object to be optionally provided when instantiating a
  30466. * {@link Request}.
  30467. *
  30468. * This class is based on the `RequestInit` description in the [Fetch
  30469. * Spec](https://fetch.spec.whatwg.org/#requestinit).
  30470. *
  30471. * All values are null by default. Typical defaults can be found in the {@link BaseRequestOptions}
  30472. * class, which sub-classes `RequestOptions`.
  30473. *
  30474. * ### Example ([live demo](http://plnkr.co/edit/7Wvi3lfLq41aQPKlxB4O?p=preview))
  30475. *
  30476. * ```typescript
  30477. * import {RequestOptions, Request, RequestMethod} from 'angular2/http';
  30478. *
  30479. * var options = new RequestOptions({
  30480. * method: RequestMethod.Post,
  30481. * url: 'https://google.com'
  30482. * });
  30483. * var req = new Request(options);
  30484. * console.log('req.method:', RequestMethod[req.method]); // Post
  30485. * console.log('options.url:', options.url); // https://google.com
  30486. * ```
  30487. */
  30488. var RequestOptions = (function () {
  30489. function RequestOptions(_a) {
  30490. var _b = _a === void 0 ? {} : _a, method = _b.method, headers = _b.headers, body = _b.body, url = _b.url, search = _b.search;
  30491. this.method = lang_1.isPresent(method) ? http_utils_1.normalizeMethodName(method) : null;
  30492. this.headers = lang_1.isPresent(headers) ? headers : null;
  30493. this.body = lang_1.isPresent(body) ? body : null;
  30494. this.url = lang_1.isPresent(url) ? url : null;
  30495. this.search = lang_1.isPresent(search) ? (lang_1.isString(search) ? new url_search_params_1.URLSearchParams((search)) :
  30496. (search)) :
  30497. null;
  30498. }
  30499. /**
  30500. * Creates a copy of the `RequestOptions` instance, using the optional input as values to override
  30501. * existing values. This method will not change the values of the instance on which it is being
  30502. * called.
  30503. *
  30504. * Note that `headers` and `search` will override existing values completely if present in
  30505. * the `options` object. If these values should be merged, it should be done prior to calling
  30506. * `merge` on the `RequestOptions` instance.
  30507. *
  30508. * ### Example ([live demo](http://plnkr.co/edit/6w8XA8YTkDRcPYpdB9dk?p=preview))
  30509. *
  30510. * ```typescript
  30511. * import {RequestOptions, Request, RequestMethod} from 'angular2/http';
  30512. *
  30513. * var options = new RequestOptions({
  30514. * method: RequestMethod.Post
  30515. * });
  30516. * var req = new Request(options.merge({
  30517. * url: 'https://google.com'
  30518. * }));
  30519. * console.log('req.method:', RequestMethod[req.method]); // Post
  30520. * console.log('options.url:', options.url); // null
  30521. * console.log('req.url:', req.url); // https://google.com
  30522. * ```
  30523. */
  30524. RequestOptions.prototype.merge = function (options) {
  30525. return new RequestOptions({
  30526. method: lang_1.isPresent(options) && lang_1.isPresent(options.method) ? options.method : this.method,
  30527. headers: lang_1.isPresent(options) && lang_1.isPresent(options.headers) ? options.headers : this.headers,
  30528. body: lang_1.isPresent(options) && lang_1.isPresent(options.body) ? options.body : this.body,
  30529. url: lang_1.isPresent(options) && lang_1.isPresent(options.url) ? options.url : this.url,
  30530. search: lang_1.isPresent(options) && lang_1.isPresent(options.search) ?
  30531. (lang_1.isString(options.search) ? new url_search_params_1.URLSearchParams((options.search)) :
  30532. (options.search).clone()) :
  30533. this.search
  30534. });
  30535. };
  30536. return RequestOptions;
  30537. })();
  30538. exports.RequestOptions = RequestOptions;
  30539. /**
  30540. * Subclass of {@link RequestOptions}, with default values.
  30541. *
  30542. * Default values:
  30543. * * method: {@link RequestMethod RequestMethod.Get}
  30544. * * headers: empty {@link Headers} object
  30545. *
  30546. * This class could be extended and bound to the {@link RequestOptions} class
  30547. * when configuring an {@link Injector}, in order to override the default options
  30548. * used by {@link Http} to create and send {@link Request Requests}.
  30549. *
  30550. * ### Example ([live demo](http://plnkr.co/edit/LEKVSx?p=preview))
  30551. *
  30552. * ```typescript
  30553. * import {provide} from 'angular2/core';
  30554. * import {bootstrap} from 'angular2/platform/browser';
  30555. * import {HTTP_PROVIDERS, Http, BaseRequestOptions, RequestOptions} from 'angular2/http';
  30556. * import {App} from './myapp';
  30557. *
  30558. * class MyOptions extends BaseRequestOptions {
  30559. * search: string = 'coreTeam=true';
  30560. * }
  30561. *
  30562. * bootstrap(App, [HTTP_PROVIDERS, provide(RequestOptions, {useClass: MyOptions})]);
  30563. * ```
  30564. *
  30565. * The options could also be extended when manually creating a {@link Request}
  30566. * object.
  30567. *
  30568. * ### Example ([live demo](http://plnkr.co/edit/oyBoEvNtDhOSfi9YxaVb?p=preview))
  30569. *
  30570. * ```
  30571. * import {BaseRequestOptions, Request, RequestMethod} from 'angular2/http';
  30572. *
  30573. * var options = new BaseRequestOptions();
  30574. * var req = new Request(options.merge({
  30575. * method: RequestMethod.Post,
  30576. * url: 'https://google.com'
  30577. * }));
  30578. * console.log('req.method:', RequestMethod[req.method]); // Post
  30579. * console.log('options.url:', options.url); // null
  30580. * console.log('req.url:', req.url); // https://google.com
  30581. * ```
  30582. */
  30583. var BaseRequestOptions = (function (_super) {
  30584. __extends(BaseRequestOptions, _super);
  30585. function BaseRequestOptions() {
  30586. _super.call(this, { method: enums_1.RequestMethod.Get, headers: new headers_1.Headers() });
  30587. }
  30588. BaseRequestOptions = __decorate([
  30589. core_1.Injectable(),
  30590. __metadata('design:paramtypes', [])
  30591. ], BaseRequestOptions);
  30592. return BaseRequestOptions;
  30593. })(RequestOptions);
  30594. exports.BaseRequestOptions = BaseRequestOptions;
  30595. /***/ },
  30596. /* 217 */
  30597. /***/ function(module, exports, __webpack_require__) {
  30598. var lang_1 = __webpack_require__(5);
  30599. var collection_1 = __webpack_require__(12);
  30600. function paramParser(rawParams) {
  30601. if (rawParams === void 0) { rawParams = ''; }
  30602. var map = new collection_1.Map();
  30603. if (rawParams.length > 0) {
  30604. var params = rawParams.split('&');
  30605. params.forEach(function (param) {
  30606. var split = param.split('=');
  30607. var key = split[0];
  30608. var val = split[1];
  30609. var list = lang_1.isPresent(map.get(key)) ? map.get(key) : [];
  30610. list.push(val);
  30611. map.set(key, list);
  30612. });
  30613. }
  30614. return map;
  30615. }
  30616. /**
  30617. * Map-like representation of url search parameters, based on
  30618. * [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams) in the url living standard,
  30619. * with several extensions for merging URLSearchParams objects:
  30620. * - setAll()
  30621. * - appendAll()
  30622. * - replaceAll()
  30623. */
  30624. var URLSearchParams = (function () {
  30625. function URLSearchParams(rawParams) {
  30626. if (rawParams === void 0) { rawParams = ''; }
  30627. this.rawParams = rawParams;
  30628. this.paramsMap = paramParser(rawParams);
  30629. }
  30630. URLSearchParams.prototype.clone = function () {
  30631. var clone = new URLSearchParams();
  30632. clone.appendAll(this);
  30633. return clone;
  30634. };
  30635. URLSearchParams.prototype.has = function (param) { return this.paramsMap.has(param); };
  30636. URLSearchParams.prototype.get = function (param) {
  30637. var storedParam = this.paramsMap.get(param);
  30638. if (collection_1.isListLikeIterable(storedParam)) {
  30639. return collection_1.ListWrapper.first(storedParam);
  30640. }
  30641. else {
  30642. return null;
  30643. }
  30644. };
  30645. URLSearchParams.prototype.getAll = function (param) {
  30646. var mapParam = this.paramsMap.get(param);
  30647. return lang_1.isPresent(mapParam) ? mapParam : [];
  30648. };
  30649. URLSearchParams.prototype.set = function (param, val) {
  30650. var mapParam = this.paramsMap.get(param);
  30651. var list = lang_1.isPresent(mapParam) ? mapParam : [];
  30652. collection_1.ListWrapper.clear(list);
  30653. list.push(val);
  30654. this.paramsMap.set(param, list);
  30655. };
  30656. // A merge operation
  30657. // For each name-values pair in `searchParams`, perform `set(name, values[0])`
  30658. //
  30659. // E.g: "a=[1,2,3], c=[8]" + "a=[4,5,6], b=[7]" = "a=[4], c=[8], b=[7]"
  30660. //
  30661. // TODO(@caitp): document this better
  30662. URLSearchParams.prototype.setAll = function (searchParams) {
  30663. var _this = this;
  30664. searchParams.paramsMap.forEach(function (value, param) {
  30665. var mapParam = _this.paramsMap.get(param);
  30666. var list = lang_1.isPresent(mapParam) ? mapParam : [];
  30667. collection_1.ListWrapper.clear(list);
  30668. list.push(value[0]);
  30669. _this.paramsMap.set(param, list);
  30670. });
  30671. };
  30672. URLSearchParams.prototype.append = function (param, val) {
  30673. var mapParam = this.paramsMap.get(param);
  30674. var list = lang_1.isPresent(mapParam) ? mapParam : [];
  30675. list.push(val);
  30676. this.paramsMap.set(param, list);
  30677. };
  30678. // A merge operation
  30679. // For each name-values pair in `searchParams`, perform `append(name, value)`
  30680. // for each value in `values`.
  30681. //
  30682. // E.g: "a=[1,2], c=[8]" + "a=[3,4], b=[7]" = "a=[1,2,3,4], c=[8], b=[7]"
  30683. //
  30684. // TODO(@caitp): document this better
  30685. URLSearchParams.prototype.appendAll = function (searchParams) {
  30686. var _this = this;
  30687. searchParams.paramsMap.forEach(function (value, param) {
  30688. var mapParam = _this.paramsMap.get(param);
  30689. var list = lang_1.isPresent(mapParam) ? mapParam : [];
  30690. for (var i = 0; i < value.length; ++i) {
  30691. list.push(value[i]);
  30692. }
  30693. _this.paramsMap.set(param, list);
  30694. });
  30695. };
  30696. // A merge operation
  30697. // For each name-values pair in `searchParams`, perform `delete(name)`,
  30698. // followed by `set(name, values)`
  30699. //
  30700. // E.g: "a=[1,2,3], c=[8]" + "a=[4,5,6], b=[7]" = "a=[4,5,6], c=[8], b=[7]"
  30701. //
  30702. // TODO(@caitp): document this better
  30703. URLSearchParams.prototype.replaceAll = function (searchParams) {
  30704. var _this = this;
  30705. searchParams.paramsMap.forEach(function (value, param) {
  30706. var mapParam = _this.paramsMap.get(param);
  30707. var list = lang_1.isPresent(mapParam) ? mapParam : [];
  30708. collection_1.ListWrapper.clear(list);
  30709. for (var i = 0; i < value.length; ++i) {
  30710. list.push(value[i]);
  30711. }
  30712. _this.paramsMap.set(param, list);
  30713. });
  30714. };
  30715. URLSearchParams.prototype.toString = function () {
  30716. var paramsList = [];
  30717. this.paramsMap.forEach(function (values, k) { values.forEach(function (v) { return paramsList.push(k + '=' + v); }); });
  30718. return paramsList.join('&');
  30719. };
  30720. URLSearchParams.prototype.delete = function (param) { this.paramsMap.delete(param); };
  30721. return URLSearchParams;
  30722. })();
  30723. exports.URLSearchParams = URLSearchParams;
  30724. /***/ },
  30725. /* 218 */
  30726. /***/ function(module, exports, __webpack_require__) {
  30727. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  30728. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  30729. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  30730. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  30731. return c > 3 && r && Object.defineProperty(target, key, r), r;
  30732. };
  30733. var __metadata = (this && this.__metadata) || function (k, v) {
  30734. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  30735. };
  30736. var enums_1 = __webpack_require__(215);
  30737. var static_response_1 = __webpack_require__(219);
  30738. var headers_1 = __webpack_require__(213);
  30739. var base_response_options_1 = __webpack_require__(220);
  30740. var core_1 = __webpack_require__(2);
  30741. var browser_xhr_1 = __webpack_require__(221);
  30742. var lang_1 = __webpack_require__(5);
  30743. var Observable_1 = __webpack_require__(62);
  30744. var http_utils_1 = __webpack_require__(214);
  30745. /**
  30746. * Creates connections using `XMLHttpRequest`. Given a fully-qualified
  30747. * request, an `XHRConnection` will immediately create an `XMLHttpRequest` object and send the
  30748. * request.
  30749. *
  30750. * This class would typically not be created or interacted with directly inside applications, though
  30751. * the {@link MockConnection} may be interacted with in tests.
  30752. */
  30753. var XHRConnection = (function () {
  30754. function XHRConnection(req, browserXHR, baseResponseOptions) {
  30755. var _this = this;
  30756. this.request = req;
  30757. this.response = new Observable_1.Observable(function (responseObserver) {
  30758. var _xhr = browserXHR.build();
  30759. _xhr.open(enums_1.RequestMethod[req.method].toUpperCase(), req.url);
  30760. // load event handler
  30761. var onLoad = function () {
  30762. // responseText is the old-school way of retrieving response (supported by IE8 & 9)
  30763. // response/responseType properties were introduced in XHR Level2 spec (supported by
  30764. // IE10)
  30765. var body = lang_1.isPresent(_xhr.response) ? _xhr.response : _xhr.responseText;
  30766. var headers = headers_1.Headers.fromResponseHeaderString(_xhr.getAllResponseHeaders());
  30767. var url = http_utils_1.getResponseURL(_xhr);
  30768. // normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
  30769. var status = _xhr.status === 1223 ? 204 : _xhr.status;
  30770. // fix status code when it is 0 (0 status is undocumented).
  30771. // Occurs when accessing file resources or on Android 4.1 stock browser
  30772. // while retrieving files from application cache.
  30773. if (status === 0) {
  30774. status = body ? 200 : 0;
  30775. }
  30776. var responseOptions = new base_response_options_1.ResponseOptions({ body: body, status: status, headers: headers, url: url });
  30777. if (lang_1.isPresent(baseResponseOptions)) {
  30778. responseOptions = baseResponseOptions.merge(responseOptions);
  30779. }
  30780. var response = new static_response_1.Response(responseOptions);
  30781. if (http_utils_1.isSuccess(status)) {
  30782. responseObserver.next(response);
  30783. // TODO(gdi2290): defer complete if array buffer until done
  30784. responseObserver.complete();
  30785. return;
  30786. }
  30787. responseObserver.error(response);
  30788. };
  30789. // error event handler
  30790. var onError = function (err) {
  30791. var responseOptions = new base_response_options_1.ResponseOptions({ body: err, type: enums_1.ResponseType.Error });
  30792. if (lang_1.isPresent(baseResponseOptions)) {
  30793. responseOptions = baseResponseOptions.merge(responseOptions);
  30794. }
  30795. responseObserver.error(new static_response_1.Response(responseOptions));
  30796. };
  30797. if (lang_1.isPresent(req.headers)) {
  30798. req.headers.forEach(function (values, name) { return _xhr.setRequestHeader(name, values.join(',')); });
  30799. }
  30800. _xhr.addEventListener('load', onLoad);
  30801. _xhr.addEventListener('error', onError);
  30802. _xhr.send(_this.request.text());
  30803. return function () {
  30804. _xhr.removeEventListener('load', onLoad);
  30805. _xhr.removeEventListener('error', onError);
  30806. _xhr.abort();
  30807. };
  30808. });
  30809. }
  30810. return XHRConnection;
  30811. })();
  30812. exports.XHRConnection = XHRConnection;
  30813. /**
  30814. * Creates {@link XHRConnection} instances.
  30815. *
  30816. * This class would typically not be used by end users, but could be
  30817. * overridden if a different backend implementation should be used,
  30818. * such as in a node backend.
  30819. *
  30820. * ### Example
  30821. *
  30822. * ```
  30823. * import {Http, MyNodeBackend, HTTP_PROVIDERS, BaseRequestOptions} from 'angular2/http';
  30824. * @Component({
  30825. * viewProviders: [
  30826. * HTTP_PROVIDERS,
  30827. * provide(Http, {useFactory: (backend, options) => {
  30828. * return new Http(backend, options);
  30829. * }, deps: [MyNodeBackend, BaseRequestOptions]})]
  30830. * })
  30831. * class MyComponent {
  30832. * constructor(http:Http) {
  30833. * http.request('people.json').subscribe(res => this.people = res.json());
  30834. * }
  30835. * }
  30836. * ```
  30837. *
  30838. **/
  30839. var XHRBackend = (function () {
  30840. function XHRBackend(_browserXHR, _baseResponseOptions) {
  30841. this._browserXHR = _browserXHR;
  30842. this._baseResponseOptions = _baseResponseOptions;
  30843. }
  30844. XHRBackend.prototype.createConnection = function (request) {
  30845. return new XHRConnection(request, this._browserXHR, this._baseResponseOptions);
  30846. };
  30847. XHRBackend = __decorate([
  30848. core_1.Injectable(),
  30849. __metadata('design:paramtypes', [browser_xhr_1.BrowserXhr, base_response_options_1.ResponseOptions])
  30850. ], XHRBackend);
  30851. return XHRBackend;
  30852. })();
  30853. exports.XHRBackend = XHRBackend;
  30854. /***/ },
  30855. /* 219 */
  30856. /***/ function(module, exports, __webpack_require__) {
  30857. var lang_1 = __webpack_require__(5);
  30858. var exceptions_1 = __webpack_require__(14);
  30859. var http_utils_1 = __webpack_require__(214);
  30860. /**
  30861. * Creates `Response` instances from provided values.
  30862. *
  30863. * Though this object isn't
  30864. * usually instantiated by end-users, it is the primary object interacted with when it comes time to
  30865. * add data to a view.
  30866. *
  30867. * ### Example
  30868. *
  30869. * ```
  30870. * http.request('my-friends.txt').subscribe(response => this.friends = response.text());
  30871. * ```
  30872. *
  30873. * The Response's interface is inspired by the Response constructor defined in the [Fetch
  30874. * Spec](https://fetch.spec.whatwg.org/#response-class), but is considered a static value whose body
  30875. * can be accessed many times. There are other differences in the implementation, but this is the
  30876. * most significant.
  30877. */
  30878. var Response = (function () {
  30879. function Response(responseOptions) {
  30880. this._body = responseOptions.body;
  30881. this.status = responseOptions.status;
  30882. this.statusText = responseOptions.statusText;
  30883. this.headers = responseOptions.headers;
  30884. this.type = responseOptions.type;
  30885. this.url = responseOptions.url;
  30886. }
  30887. /**
  30888. * Not yet implemented
  30889. */
  30890. // TODO: Blob return type
  30891. Response.prototype.blob = function () { throw new exceptions_1.BaseException('"blob()" method not implemented on Response superclass'); };
  30892. /**
  30893. * Attempts to return body as parsed `JSON` object, or raises an exception.
  30894. */
  30895. Response.prototype.json = function () {
  30896. var jsonResponse;
  30897. if (http_utils_1.isJsObject(this._body)) {
  30898. jsonResponse = this._body;
  30899. }
  30900. else if (lang_1.isString(this._body)) {
  30901. jsonResponse = lang_1.Json.parse(this._body);
  30902. }
  30903. return jsonResponse;
  30904. };
  30905. /**
  30906. * Returns the body as a string, presuming `toString()` can be called on the response body.
  30907. */
  30908. Response.prototype.text = function () { return this._body.toString(); };
  30909. /**
  30910. * Not yet implemented
  30911. */
  30912. // TODO: ArrayBuffer return type
  30913. Response.prototype.arrayBuffer = function () {
  30914. throw new exceptions_1.BaseException('"arrayBuffer()" method not implemented on Response superclass');
  30915. };
  30916. return Response;
  30917. })();
  30918. exports.Response = Response;
  30919. /***/ },
  30920. /* 220 */
  30921. /***/ function(module, exports, __webpack_require__) {
  30922. var __extends = (this && this.__extends) || function (d, b) {
  30923. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  30924. function __() { this.constructor = d; }
  30925. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30926. };
  30927. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  30928. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  30929. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  30930. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  30931. return c > 3 && r && Object.defineProperty(target, key, r), r;
  30932. };
  30933. var __metadata = (this && this.__metadata) || function (k, v) {
  30934. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  30935. };
  30936. var core_1 = __webpack_require__(2);
  30937. var lang_1 = __webpack_require__(5);
  30938. var headers_1 = __webpack_require__(213);
  30939. var enums_1 = __webpack_require__(215);
  30940. /**
  30941. * Creates a response options object to be optionally provided when instantiating a
  30942. * {@link Response}.
  30943. *
  30944. * This class is based on the `ResponseInit` description in the [Fetch
  30945. * Spec](https://fetch.spec.whatwg.org/#responseinit).
  30946. *
  30947. * All values are null by default. Typical defaults can be found in the
  30948. * {@link BaseResponseOptions} class, which sub-classes `ResponseOptions`.
  30949. *
  30950. * This class may be used in tests to build {@link Response Responses} for
  30951. * mock responses (see {@link MockBackend}).
  30952. *
  30953. * ### Example ([live demo](http://plnkr.co/edit/P9Jkk8e8cz6NVzbcxEsD?p=preview))
  30954. *
  30955. * ```typescript
  30956. * import {ResponseOptions, Response} from 'angular2/http';
  30957. *
  30958. * var options = new ResponseOptions({
  30959. * body: '{"name":"Jeff"}'
  30960. * });
  30961. * var res = new Response(options);
  30962. *
  30963. * console.log('res.json():', res.json()); // Object {name: "Jeff"}
  30964. * ```
  30965. */
  30966. var ResponseOptions = (function () {
  30967. function ResponseOptions(_a) {
  30968. var _b = _a === void 0 ? {} : _a, body = _b.body, status = _b.status, headers = _b.headers, statusText = _b.statusText, type = _b.type, url = _b.url;
  30969. this.body = lang_1.isPresent(body) ? body : null;
  30970. this.status = lang_1.isPresent(status) ? status : null;
  30971. this.headers = lang_1.isPresent(headers) ? headers : null;
  30972. this.statusText = lang_1.isPresent(statusText) ? statusText : null;
  30973. this.type = lang_1.isPresent(type) ? type : null;
  30974. this.url = lang_1.isPresent(url) ? url : null;
  30975. }
  30976. /**
  30977. * Creates a copy of the `ResponseOptions` instance, using the optional input as values to
  30978. * override
  30979. * existing values. This method will not change the values of the instance on which it is being
  30980. * called.
  30981. *
  30982. * This may be useful when sharing a base `ResponseOptions` object inside tests,
  30983. * where certain properties may change from test to test.
  30984. *
  30985. * ### Example ([live demo](http://plnkr.co/edit/1lXquqFfgduTFBWjNoRE?p=preview))
  30986. *
  30987. * ```typescript
  30988. * import {ResponseOptions, Response} from 'angular2/http';
  30989. *
  30990. * var options = new ResponseOptions({
  30991. * body: {name: 'Jeff'}
  30992. * });
  30993. * var res = new Response(options.merge({
  30994. * url: 'https://google.com'
  30995. * }));
  30996. * console.log('options.url:', options.url); // null
  30997. * console.log('res.json():', res.json()); // Object {name: "Jeff"}
  30998. * console.log('res.url:', res.url); // https://google.com
  30999. * ```
  31000. */
  31001. ResponseOptions.prototype.merge = function (options) {
  31002. return new ResponseOptions({
  31003. body: lang_1.isPresent(options) && lang_1.isPresent(options.body) ? options.body : this.body,
  31004. status: lang_1.isPresent(options) && lang_1.isPresent(options.status) ? options.status : this.status,
  31005. headers: lang_1.isPresent(options) && lang_1.isPresent(options.headers) ? options.headers : this.headers,
  31006. statusText: lang_1.isPresent(options) && lang_1.isPresent(options.statusText) ? options.statusText :
  31007. this.statusText,
  31008. type: lang_1.isPresent(options) && lang_1.isPresent(options.type) ? options.type : this.type,
  31009. url: lang_1.isPresent(options) && lang_1.isPresent(options.url) ? options.url : this.url,
  31010. });
  31011. };
  31012. return ResponseOptions;
  31013. })();
  31014. exports.ResponseOptions = ResponseOptions;
  31015. /**
  31016. * Subclass of {@link ResponseOptions}, with default values.
  31017. *
  31018. * Default values:
  31019. * * status: 200
  31020. * * headers: empty {@link Headers} object
  31021. *
  31022. * This class could be extended and bound to the {@link ResponseOptions} class
  31023. * when configuring an {@link Injector}, in order to override the default options
  31024. * used by {@link Http} to create {@link Response Responses}.
  31025. *
  31026. * ### Example ([live demo](http://plnkr.co/edit/qv8DLT?p=preview))
  31027. *
  31028. * ```typescript
  31029. * import {provide} from 'angular2/core';
  31030. * import {bootstrap} from 'angular2/platform/browser';
  31031. * import {HTTP_PROVIDERS, Headers, Http, BaseResponseOptions, ResponseOptions} from
  31032. * 'angular2/http';
  31033. * import {App} from './myapp';
  31034. *
  31035. * class MyOptions extends BaseResponseOptions {
  31036. * headers:Headers = new Headers({network: 'github'});
  31037. * }
  31038. *
  31039. * bootstrap(App, [HTTP_PROVIDERS, provide(ResponseOptions, {useClass: MyOptions})]);
  31040. * ```
  31041. *
  31042. * The options could also be extended when manually creating a {@link Response}
  31043. * object.
  31044. *
  31045. * ### Example ([live demo](http://plnkr.co/edit/VngosOWiaExEtbstDoix?p=preview))
  31046. *
  31047. * ```
  31048. * import {BaseResponseOptions, Response} from 'angular2/http';
  31049. *
  31050. * var options = new BaseResponseOptions();
  31051. * var res = new Response(options.merge({
  31052. * body: 'Angular2',
  31053. * headers: new Headers({framework: 'angular'})
  31054. * }));
  31055. * console.log('res.headers.get("framework"):', res.headers.get('framework')); // angular
  31056. * console.log('res.text():', res.text()); // Angular2;
  31057. * ```
  31058. */
  31059. var BaseResponseOptions = (function (_super) {
  31060. __extends(BaseResponseOptions, _super);
  31061. function BaseResponseOptions() {
  31062. _super.call(this, { status: 200, statusText: 'Ok', type: enums_1.ResponseType.Default, headers: new headers_1.Headers() });
  31063. }
  31064. BaseResponseOptions = __decorate([
  31065. core_1.Injectable(),
  31066. __metadata('design:paramtypes', [])
  31067. ], BaseResponseOptions);
  31068. return BaseResponseOptions;
  31069. })(ResponseOptions);
  31070. exports.BaseResponseOptions = BaseResponseOptions;
  31071. /***/ },
  31072. /* 221 */
  31073. /***/ function(module, exports, __webpack_require__) {
  31074. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  31075. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  31076. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  31077. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  31078. return c > 3 && r && Object.defineProperty(target, key, r), r;
  31079. };
  31080. var __metadata = (this && this.__metadata) || function (k, v) {
  31081. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  31082. };
  31083. var core_1 = __webpack_require__(2);
  31084. /**
  31085. * A backend for http that uses the `XMLHttpRequest` browser API.
  31086. *
  31087. * Take care not to evaluate this in non-browser contexts.
  31088. */
  31089. var BrowserXhr = (function () {
  31090. function BrowserXhr() {
  31091. }
  31092. BrowserXhr.prototype.build = function () { return (new XMLHttpRequest()); };
  31093. BrowserXhr = __decorate([
  31094. core_1.Injectable(),
  31095. __metadata('design:paramtypes', [])
  31096. ], BrowserXhr);
  31097. return BrowserXhr;
  31098. })();
  31099. exports.BrowserXhr = BrowserXhr;
  31100. /***/ },
  31101. /* 222 */
  31102. /***/ function(module, exports, __webpack_require__) {
  31103. var __extends = (this && this.__extends) || function (d, b) {
  31104. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31105. function __() { this.constructor = d; }
  31106. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31107. };
  31108. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  31109. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  31110. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  31111. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  31112. return c > 3 && r && Object.defineProperty(target, key, r), r;
  31113. };
  31114. var __metadata = (this && this.__metadata) || function (k, v) {
  31115. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  31116. };
  31117. var interfaces_1 = __webpack_require__(211);
  31118. var enums_1 = __webpack_require__(215);
  31119. var static_response_1 = __webpack_require__(219);
  31120. var base_response_options_1 = __webpack_require__(220);
  31121. var core_1 = __webpack_require__(2);
  31122. var browser_jsonp_1 = __webpack_require__(223);
  31123. var exceptions_1 = __webpack_require__(14);
  31124. var lang_1 = __webpack_require__(5);
  31125. var Observable_1 = __webpack_require__(62);
  31126. var JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.';
  31127. var JSONP_ERR_WRONG_METHOD = 'JSONP requests must use GET request method.';
  31128. /**
  31129. * Abstract base class for an in-flight JSONP request.
  31130. */
  31131. var JSONPConnection = (function () {
  31132. function JSONPConnection() {
  31133. }
  31134. return JSONPConnection;
  31135. })();
  31136. exports.JSONPConnection = JSONPConnection;
  31137. var JSONPConnection_ = (function (_super) {
  31138. __extends(JSONPConnection_, _super);
  31139. function JSONPConnection_(req, _dom, baseResponseOptions) {
  31140. var _this = this;
  31141. _super.call(this);
  31142. this._dom = _dom;
  31143. this.baseResponseOptions = baseResponseOptions;
  31144. this._finished = false;
  31145. if (req.method !== enums_1.RequestMethod.Get) {
  31146. throw exceptions_1.makeTypeError(JSONP_ERR_WRONG_METHOD);
  31147. }
  31148. this.request = req;
  31149. this.response = new Observable_1.Observable(function (responseObserver) {
  31150. _this.readyState = enums_1.ReadyState.Loading;
  31151. var id = _this._id = _dom.nextRequestID();
  31152. _dom.exposeConnection(id, _this);
  31153. // Workaround Dart
  31154. // url = url.replace(/=JSONP_CALLBACK(&|$)/, `generated method`);
  31155. var callback = _dom.requestCallback(_this._id);
  31156. var url = req.url;
  31157. if (url.indexOf('=JSONP_CALLBACK&') > -1) {
  31158. url = lang_1.StringWrapper.replace(url, '=JSONP_CALLBACK&', "=" + callback + "&");
  31159. }
  31160. else if (url.lastIndexOf('=JSONP_CALLBACK') === url.length - '=JSONP_CALLBACK'.length) {
  31161. url = url.substring(0, url.length - '=JSONP_CALLBACK'.length) + ("=" + callback);
  31162. }
  31163. var script = _this._script = _dom.build(url);
  31164. var onLoad = function (event) {
  31165. if (_this.readyState === enums_1.ReadyState.Cancelled)
  31166. return;
  31167. _this.readyState = enums_1.ReadyState.Done;
  31168. _dom.cleanup(script);
  31169. if (!_this._finished) {
  31170. var responseOptions_1 = new base_response_options_1.ResponseOptions({ body: JSONP_ERR_NO_CALLBACK, type: enums_1.ResponseType.Error, url: url });
  31171. if (lang_1.isPresent(baseResponseOptions)) {
  31172. responseOptions_1 = baseResponseOptions.merge(responseOptions_1);
  31173. }
  31174. responseObserver.error(new static_response_1.Response(responseOptions_1));
  31175. return;
  31176. }
  31177. var responseOptions = new base_response_options_1.ResponseOptions({ body: _this._responseData, url: url });
  31178. if (lang_1.isPresent(_this.baseResponseOptions)) {
  31179. responseOptions = _this.baseResponseOptions.merge(responseOptions);
  31180. }
  31181. responseObserver.next(new static_response_1.Response(responseOptions));
  31182. responseObserver.complete();
  31183. };
  31184. var onError = function (error) {
  31185. if (_this.readyState === enums_1.ReadyState.Cancelled)
  31186. return;
  31187. _this.readyState = enums_1.ReadyState.Done;
  31188. _dom.cleanup(script);
  31189. var responseOptions = new base_response_options_1.ResponseOptions({ body: error.message, type: enums_1.ResponseType.Error });
  31190. if (lang_1.isPresent(baseResponseOptions)) {
  31191. responseOptions = baseResponseOptions.merge(responseOptions);
  31192. }
  31193. responseObserver.error(new static_response_1.Response(responseOptions));
  31194. };
  31195. script.addEventListener('load', onLoad);
  31196. script.addEventListener('error', onError);
  31197. _dom.send(script);
  31198. return function () {
  31199. _this.readyState = enums_1.ReadyState.Cancelled;
  31200. script.removeEventListener('load', onLoad);
  31201. script.removeEventListener('error', onError);
  31202. if (lang_1.isPresent(script)) {
  31203. _this._dom.cleanup(script);
  31204. }
  31205. };
  31206. });
  31207. }
  31208. JSONPConnection_.prototype.finished = function (data) {
  31209. // Don't leak connections
  31210. this._finished = true;
  31211. this._dom.removeConnection(this._id);
  31212. if (this.readyState === enums_1.ReadyState.Cancelled)
  31213. return;
  31214. this._responseData = data;
  31215. };
  31216. return JSONPConnection_;
  31217. })(JSONPConnection);
  31218. exports.JSONPConnection_ = JSONPConnection_;
  31219. /**
  31220. * A {@link ConnectionBackend} that uses the JSONP strategy of making requests.
  31221. */
  31222. var JSONPBackend = (function (_super) {
  31223. __extends(JSONPBackend, _super);
  31224. function JSONPBackend() {
  31225. _super.apply(this, arguments);
  31226. }
  31227. return JSONPBackend;
  31228. })(interfaces_1.ConnectionBackend);
  31229. exports.JSONPBackend = JSONPBackend;
  31230. var JSONPBackend_ = (function (_super) {
  31231. __extends(JSONPBackend_, _super);
  31232. function JSONPBackend_(_browserJSONP, _baseResponseOptions) {
  31233. _super.call(this);
  31234. this._browserJSONP = _browserJSONP;
  31235. this._baseResponseOptions = _baseResponseOptions;
  31236. }
  31237. JSONPBackend_.prototype.createConnection = function (request) {
  31238. return new JSONPConnection_(request, this._browserJSONP, this._baseResponseOptions);
  31239. };
  31240. JSONPBackend_ = __decorate([
  31241. core_1.Injectable(),
  31242. __metadata('design:paramtypes', [browser_jsonp_1.BrowserJsonp, base_response_options_1.ResponseOptions])
  31243. ], JSONPBackend_);
  31244. return JSONPBackend_;
  31245. })(JSONPBackend);
  31246. exports.JSONPBackend_ = JSONPBackend_;
  31247. /***/ },
  31248. /* 223 */
  31249. /***/ function(module, exports, __webpack_require__) {
  31250. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  31251. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  31252. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  31253. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  31254. return c > 3 && r && Object.defineProperty(target, key, r), r;
  31255. };
  31256. var __metadata = (this && this.__metadata) || function (k, v) {
  31257. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  31258. };
  31259. var core_1 = __webpack_require__(2);
  31260. var lang_1 = __webpack_require__(5);
  31261. var _nextRequestId = 0;
  31262. exports.JSONP_HOME = '__ng_jsonp__';
  31263. var _jsonpConnections = null;
  31264. function _getJsonpConnections() {
  31265. if (_jsonpConnections === null) {
  31266. _jsonpConnections = lang_1.global[exports.JSONP_HOME] = {};
  31267. }
  31268. return _jsonpConnections;
  31269. }
  31270. // Make sure not to evaluate this in a non-browser environment!
  31271. var BrowserJsonp = (function () {
  31272. function BrowserJsonp() {
  31273. }
  31274. // Construct a <script> element with the specified URL
  31275. BrowserJsonp.prototype.build = function (url) {
  31276. var node = document.createElement('script');
  31277. node.src = url;
  31278. return node;
  31279. };
  31280. BrowserJsonp.prototype.nextRequestID = function () { return "__req" + _nextRequestId++; };
  31281. BrowserJsonp.prototype.requestCallback = function (id) { return exports.JSONP_HOME + "." + id + ".finished"; };
  31282. BrowserJsonp.prototype.exposeConnection = function (id, connection) {
  31283. var connections = _getJsonpConnections();
  31284. connections[id] = connection;
  31285. };
  31286. BrowserJsonp.prototype.removeConnection = function (id) {
  31287. var connections = _getJsonpConnections();
  31288. connections[id] = null;
  31289. };
  31290. // Attach the <script> element to the DOM
  31291. BrowserJsonp.prototype.send = function (node) { document.body.appendChild((node)); };
  31292. // Remove <script> element from the DOM
  31293. BrowserJsonp.prototype.cleanup = function (node) {
  31294. if (node.parentNode) {
  31295. node.parentNode.removeChild((node));
  31296. }
  31297. };
  31298. BrowserJsonp = __decorate([
  31299. core_1.Injectable(),
  31300. __metadata('design:paramtypes', [])
  31301. ], BrowserJsonp);
  31302. return BrowserJsonp;
  31303. })();
  31304. exports.BrowserJsonp = BrowserJsonp;
  31305. /***/ },
  31306. /* 224 */
  31307. /***/ function(module, exports, __webpack_require__) {
  31308. /**
  31309. * @module
  31310. * @description
  31311. * Maps application URLs into application states, to support deep-linking and navigation.
  31312. */
  31313. function __export(m) {
  31314. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  31315. }
  31316. var router_1 = __webpack_require__(225);
  31317. exports.Router = router_1.Router;
  31318. var router_outlet_1 = __webpack_require__(241);
  31319. exports.RouterOutlet = router_outlet_1.RouterOutlet;
  31320. var router_link_1 = __webpack_require__(243);
  31321. exports.RouterLink = router_link_1.RouterLink;
  31322. var instruction_1 = __webpack_require__(229);
  31323. exports.RouteParams = instruction_1.RouteParams;
  31324. exports.RouteData = instruction_1.RouteData;
  31325. var platform_location_1 = __webpack_require__(244);
  31326. exports.PlatformLocation = platform_location_1.PlatformLocation;
  31327. var route_registry_1 = __webpack_require__(226);
  31328. exports.RouteRegistry = route_registry_1.RouteRegistry;
  31329. exports.ROUTER_PRIMARY_COMPONENT = route_registry_1.ROUTER_PRIMARY_COMPONENT;
  31330. var location_strategy_1 = __webpack_require__(238);
  31331. exports.LocationStrategy = location_strategy_1.LocationStrategy;
  31332. exports.APP_BASE_HREF = location_strategy_1.APP_BASE_HREF;
  31333. var hash_location_strategy_1 = __webpack_require__(245);
  31334. exports.HashLocationStrategy = hash_location_strategy_1.HashLocationStrategy;
  31335. var path_location_strategy_1 = __webpack_require__(246);
  31336. exports.PathLocationStrategy = path_location_strategy_1.PathLocationStrategy;
  31337. var location_1 = __webpack_require__(237);
  31338. exports.Location = location_1.Location;
  31339. __export(__webpack_require__(236));
  31340. __export(__webpack_require__(247));
  31341. var lifecycle_annotations_1 = __webpack_require__(242);
  31342. exports.CanActivate = lifecycle_annotations_1.CanActivate;
  31343. var instruction_2 = __webpack_require__(229);
  31344. exports.Instruction = instruction_2.Instruction;
  31345. exports.ComponentInstruction = instruction_2.ComponentInstruction;
  31346. var core_1 = __webpack_require__(2);
  31347. exports.OpaqueToken = core_1.OpaqueToken;
  31348. var platform_location_2 = __webpack_require__(244);
  31349. var location_strategy_2 = __webpack_require__(238);
  31350. var path_location_strategy_2 = __webpack_require__(246);
  31351. var router_2 = __webpack_require__(225);
  31352. var router_outlet_2 = __webpack_require__(241);
  31353. var router_link_2 = __webpack_require__(243);
  31354. var route_registry_2 = __webpack_require__(226);
  31355. var location_2 = __webpack_require__(237);
  31356. var core_2 = __webpack_require__(2);
  31357. var lang_1 = __webpack_require__(5);
  31358. var exceptions_1 = __webpack_require__(14);
  31359. /**
  31360. * A list of directives. To use the router directives like {@link RouterOutlet} and
  31361. * {@link RouterLink}, add this to your `directives` array in the {@link View} decorator of your
  31362. * component.
  31363. *
  31364. * ### Example ([live demo](http://plnkr.co/edit/iRUP8B5OUbxCWQ3AcIDm))
  31365. *
  31366. * ```
  31367. * import {Component} from 'angular2/core';
  31368. * import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from 'angular2/router';
  31369. *
  31370. * @Component({directives: [ROUTER_DIRECTIVES]})
  31371. * @RouteConfig([
  31372. * {...},
  31373. * ])
  31374. * class AppCmp {
  31375. * // ...
  31376. * }
  31377. *
  31378. * bootstrap(AppCmp, [ROUTER_PROVIDERS]);
  31379. * ```
  31380. */
  31381. exports.ROUTER_DIRECTIVES = lang_1.CONST_EXPR([router_outlet_2.RouterOutlet, router_link_2.RouterLink]);
  31382. /**
  31383. * A list of {@link Provider}s. To use the router, you must add this to your application.
  31384. *
  31385. * ### Example ([live demo](http://plnkr.co/edit/iRUP8B5OUbxCWQ3AcIDm))
  31386. *
  31387. * ```
  31388. * import {Component} from 'angular2/core';
  31389. * import {
  31390. * ROUTER_DIRECTIVES,
  31391. * ROUTER_PROVIDERS,
  31392. * RouteConfig
  31393. * } from 'angular2/router';
  31394. *
  31395. * @Component({directives: [ROUTER_DIRECTIVES]})
  31396. * @RouteConfig([
  31397. * {...},
  31398. * ])
  31399. * class AppCmp {
  31400. * // ...
  31401. * }
  31402. *
  31403. * bootstrap(AppCmp, [ROUTER_PROVIDERS]);
  31404. * ```
  31405. */
  31406. exports.ROUTER_PROVIDERS = lang_1.CONST_EXPR([
  31407. route_registry_2.RouteRegistry,
  31408. lang_1.CONST_EXPR(new core_2.Provider(location_strategy_2.LocationStrategy, { useClass: path_location_strategy_2.PathLocationStrategy })),
  31409. platform_location_2.PlatformLocation,
  31410. location_2.Location,
  31411. lang_1.CONST_EXPR(new core_2.Provider(router_2.Router, {
  31412. useFactory: routerFactory,
  31413. deps: lang_1.CONST_EXPR([route_registry_2.RouteRegistry, location_2.Location, route_registry_2.ROUTER_PRIMARY_COMPONENT, core_2.ApplicationRef])
  31414. })),
  31415. lang_1.CONST_EXPR(new core_2.Provider(route_registry_2.ROUTER_PRIMARY_COMPONENT, { useFactory: routerPrimaryComponentFactory, deps: lang_1.CONST_EXPR([core_2.ApplicationRef]) }))
  31416. ]);
  31417. /**
  31418. * Use {@link ROUTER_PROVIDERS} instead.
  31419. *
  31420. * @deprecated
  31421. */
  31422. exports.ROUTER_BINDINGS = exports.ROUTER_PROVIDERS;
  31423. function routerFactory(registry, location, primaryComponent, appRef) {
  31424. var rootRouter = new router_2.RootRouter(registry, location, primaryComponent);
  31425. appRef.registerDisposeListener(function () { return rootRouter.dispose(); });
  31426. return rootRouter;
  31427. }
  31428. function routerPrimaryComponentFactory(app) {
  31429. if (app.componentTypes.length == 0) {
  31430. throw new exceptions_1.BaseException("Bootstrap at least one component before injecting Router.");
  31431. }
  31432. return app.componentTypes[0];
  31433. }
  31434. /***/ },
  31435. /* 225 */
  31436. /***/ function(module, exports, __webpack_require__) {
  31437. var __extends = (this && this.__extends) || function (d, b) {
  31438. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  31439. function __() { this.constructor = d; }
  31440. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31441. };
  31442. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  31443. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  31444. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  31445. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  31446. return c > 3 && r && Object.defineProperty(target, key, r), r;
  31447. };
  31448. var __metadata = (this && this.__metadata) || function (k, v) {
  31449. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  31450. };
  31451. var __param = (this && this.__param) || function (paramIndex, decorator) {
  31452. return function (target, key) { decorator(target, key, paramIndex); }
  31453. };
  31454. var async_1 = __webpack_require__(60);
  31455. var collection_1 = __webpack_require__(12);
  31456. var lang_1 = __webpack_require__(5);
  31457. var exceptions_1 = __webpack_require__(14);
  31458. var core_1 = __webpack_require__(2);
  31459. var route_registry_1 = __webpack_require__(226);
  31460. var location_1 = __webpack_require__(237);
  31461. var route_lifecycle_reflector_1 = __webpack_require__(239);
  31462. var _resolveToTrue = async_1.PromiseWrapper.resolve(true);
  31463. var _resolveToFalse = async_1.PromiseWrapper.resolve(false);
  31464. /**
  31465. * The `Router` is responsible for mapping URLs to components.
  31466. *
  31467. * You can see the state of the router by inspecting the read-only field `router.navigating`.
  31468. * This may be useful for showing a spinner, for instance.
  31469. *
  31470. * ## Concepts
  31471. *
  31472. * Routers and component instances have a 1:1 correspondence.
  31473. *
  31474. * The router holds reference to a number of {@link RouterOutlet}.
  31475. * An outlet is a placeholder that the router dynamically fills in depending on the current URL.
  31476. *
  31477. * When the router navigates from a URL, it must first recognize it and serialize it into an
  31478. * `Instruction`.
  31479. * The router uses the `RouteRegistry` to get an `Instruction`.
  31480. */
  31481. var Router = (function () {
  31482. function Router(registry, parent, hostComponent) {
  31483. this.registry = registry;
  31484. this.parent = parent;
  31485. this.hostComponent = hostComponent;
  31486. this.navigating = false;
  31487. this._currentInstruction = null;
  31488. this._currentNavigation = _resolveToTrue;
  31489. this._outlet = null;
  31490. this._auxRouters = new collection_1.Map();
  31491. this._subject = new async_1.EventEmitter();
  31492. }
  31493. /**
  31494. * Constructs a child router. You probably don't need to use this unless you're writing a reusable
  31495. * component.
  31496. */
  31497. Router.prototype.childRouter = function (hostComponent) {
  31498. return this._childRouter = new ChildRouter(this, hostComponent);
  31499. };
  31500. /**
  31501. * Constructs a child router. You probably don't need to use this unless you're writing a reusable
  31502. * component.
  31503. */
  31504. Router.prototype.auxRouter = function (hostComponent) { return new ChildRouter(this, hostComponent); };
  31505. /**
  31506. * Register an outlet to be notified of primary route changes.
  31507. *
  31508. * You probably don't need to use this unless you're writing a reusable component.
  31509. */
  31510. Router.prototype.registerPrimaryOutlet = function (outlet) {
  31511. if (lang_1.isPresent(outlet.name)) {
  31512. throw new exceptions_1.BaseException("registerPrimaryOutlet expects to be called with an unnamed outlet.");
  31513. }
  31514. this._outlet = outlet;
  31515. if (lang_1.isPresent(this._currentInstruction)) {
  31516. return this.commit(this._currentInstruction, false);
  31517. }
  31518. return _resolveToTrue;
  31519. };
  31520. /**
  31521. * Register an outlet to notified of auxiliary route changes.
  31522. *
  31523. * You probably don't need to use this unless you're writing a reusable component.
  31524. */
  31525. Router.prototype.registerAuxOutlet = function (outlet) {
  31526. var outletName = outlet.name;
  31527. if (lang_1.isBlank(outletName)) {
  31528. throw new exceptions_1.BaseException("registerAuxOutlet expects to be called with an outlet with a name.");
  31529. }
  31530. // TODO...
  31531. // what is the host of an aux route???
  31532. var router = this.auxRouter(this.hostComponent);
  31533. this._auxRouters.set(outletName, router);
  31534. router._outlet = outlet;
  31535. var auxInstruction;
  31536. if (lang_1.isPresent(this._currentInstruction) &&
  31537. lang_1.isPresent(auxInstruction = this._currentInstruction.auxInstruction[outletName])) {
  31538. return router.commit(auxInstruction);
  31539. }
  31540. return _resolveToTrue;
  31541. };
  31542. /**
  31543. * Given an instruction, returns `true` if the instruction is currently active,
  31544. * otherwise `false`.
  31545. */
  31546. Router.prototype.isRouteActive = function (instruction) {
  31547. var router = this;
  31548. while (lang_1.isPresent(router.parent) && lang_1.isPresent(instruction.child)) {
  31549. router = router.parent;
  31550. instruction = instruction.child;
  31551. }
  31552. return lang_1.isPresent(this._currentInstruction) &&
  31553. this._currentInstruction.component == instruction.component;
  31554. };
  31555. /**
  31556. * Dynamically update the routing configuration and trigger a navigation.
  31557. *
  31558. * ### Usage
  31559. *
  31560. * ```
  31561. * router.config([
  31562. * { 'path': '/', 'component': IndexComp },
  31563. * { 'path': '/user/:id', 'component': UserComp },
  31564. * ]);
  31565. * ```
  31566. */
  31567. Router.prototype.config = function (definitions) {
  31568. var _this = this;
  31569. definitions.forEach(function (routeDefinition) { _this.registry.config(_this.hostComponent, routeDefinition); });
  31570. return this.renavigate();
  31571. };
  31572. /**
  31573. * Navigate based on the provided Route Link DSL. It's preferred to navigate with this method
  31574. * over `navigateByUrl`.
  31575. *
  31576. * ### Usage
  31577. *
  31578. * This method takes an array representing the Route Link DSL:
  31579. * ```
  31580. * ['./MyCmp', {param: 3}]
  31581. * ```
  31582. * See the {@link RouterLink} directive for more.
  31583. */
  31584. Router.prototype.navigate = function (linkParams) {
  31585. var instruction = this.generate(linkParams);
  31586. return this.navigateByInstruction(instruction, false);
  31587. };
  31588. /**
  31589. * Navigate to a URL. Returns a promise that resolves when navigation is complete.
  31590. * It's preferred to navigate with `navigate` instead of this method, since URLs are more brittle.
  31591. *
  31592. * If the given URL begins with a `/`, router will navigate absolutely.
  31593. * If the given URL does not begin with `/`, the router will navigate relative to this component.
  31594. */
  31595. Router.prototype.navigateByUrl = function (url, _skipLocationChange) {
  31596. var _this = this;
  31597. if (_skipLocationChange === void 0) { _skipLocationChange = false; }
  31598. return this._currentNavigation = this._currentNavigation.then(function (_) {
  31599. _this.lastNavigationAttempt = url;
  31600. _this._startNavigating();
  31601. return _this._afterPromiseFinishNavigating(_this.recognize(url).then(function (instruction) {
  31602. if (lang_1.isBlank(instruction)) {
  31603. return false;
  31604. }
  31605. return _this._navigate(instruction, _skipLocationChange);
  31606. }));
  31607. });
  31608. };
  31609. /**
  31610. * Navigate via the provided instruction. Returns a promise that resolves when navigation is
  31611. * complete.
  31612. */
  31613. Router.prototype.navigateByInstruction = function (instruction, _skipLocationChange) {
  31614. var _this = this;
  31615. if (_skipLocationChange === void 0) { _skipLocationChange = false; }
  31616. if (lang_1.isBlank(instruction)) {
  31617. return _resolveToFalse;
  31618. }
  31619. return this._currentNavigation = this._currentNavigation.then(function (_) {
  31620. _this._startNavigating();
  31621. return _this._afterPromiseFinishNavigating(_this._navigate(instruction, _skipLocationChange));
  31622. });
  31623. };
  31624. /** @internal */
  31625. Router.prototype._navigate = function (instruction, _skipLocationChange) {
  31626. var _this = this;
  31627. return this._settleInstruction(instruction)
  31628. .then(function (_) { return _this._routerCanReuse(instruction); })
  31629. .then(function (_) { return _this._canActivate(instruction); })
  31630. .then(function (result) {
  31631. if (!result) {
  31632. return false;
  31633. }
  31634. return _this._routerCanDeactivate(instruction)
  31635. .then(function (result) {
  31636. if (result) {
  31637. return _this.commit(instruction, _skipLocationChange)
  31638. .then(function (_) {
  31639. _this._emitNavigationFinish(instruction.toRootUrl());
  31640. return true;
  31641. });
  31642. }
  31643. });
  31644. });
  31645. };
  31646. /** @internal */
  31647. Router.prototype._settleInstruction = function (instruction) {
  31648. var _this = this;
  31649. return instruction.resolveComponent().then(function (_) {
  31650. instruction.component.reuse = false;
  31651. var unsettledInstructions = [];
  31652. if (lang_1.isPresent(instruction.child)) {
  31653. unsettledInstructions.push(_this._settleInstruction(instruction.child));
  31654. }
  31655. collection_1.StringMapWrapper.forEach(instruction.auxInstruction, function (instruction, _) {
  31656. unsettledInstructions.push(_this._settleInstruction(instruction));
  31657. });
  31658. return async_1.PromiseWrapper.all(unsettledInstructions);
  31659. });
  31660. };
  31661. Router.prototype._emitNavigationFinish = function (url) { async_1.ObservableWrapper.callEmit(this._subject, url); };
  31662. Router.prototype._afterPromiseFinishNavigating = function (promise) {
  31663. var _this = this;
  31664. return async_1.PromiseWrapper.catchError(promise.then(function (_) { return _this._finishNavigating(); }), function (err) {
  31665. _this._finishNavigating();
  31666. throw err;
  31667. });
  31668. };
  31669. /*
  31670. * Recursively set reuse flags
  31671. */
  31672. /** @internal */
  31673. Router.prototype._routerCanReuse = function (instruction) {
  31674. var _this = this;
  31675. if (lang_1.isBlank(this._outlet)) {
  31676. return _resolveToFalse;
  31677. }
  31678. return this._outlet.routerCanReuse(instruction.component)
  31679. .then(function (result) {
  31680. instruction.component.reuse = result;
  31681. if (result && lang_1.isPresent(_this._childRouter) && lang_1.isPresent(instruction.child)) {
  31682. return _this._childRouter._routerCanReuse(instruction.child);
  31683. }
  31684. });
  31685. };
  31686. Router.prototype._canActivate = function (nextInstruction) {
  31687. return canActivateOne(nextInstruction, this._currentInstruction);
  31688. };
  31689. Router.prototype._routerCanDeactivate = function (instruction) {
  31690. var _this = this;
  31691. if (lang_1.isBlank(this._outlet)) {
  31692. return _resolveToTrue;
  31693. }
  31694. var next;
  31695. var childInstruction = null;
  31696. var reuse = false;
  31697. var componentInstruction = null;
  31698. if (lang_1.isPresent(instruction)) {
  31699. childInstruction = instruction.child;
  31700. componentInstruction = instruction.component;
  31701. reuse = instruction.component.reuse;
  31702. }
  31703. if (reuse) {
  31704. next = _resolveToTrue;
  31705. }
  31706. else {
  31707. next = this._outlet.routerCanDeactivate(componentInstruction);
  31708. }
  31709. // TODO: aux route lifecycle hooks
  31710. return next.then(function (result) {
  31711. if (result == false) {
  31712. return false;
  31713. }
  31714. if (lang_1.isPresent(_this._childRouter)) {
  31715. return _this._childRouter._routerCanDeactivate(childInstruction);
  31716. }
  31717. return true;
  31718. });
  31719. };
  31720. /**
  31721. * Updates this router and all descendant routers according to the given instruction
  31722. */
  31723. Router.prototype.commit = function (instruction, _skipLocationChange) {
  31724. var _this = this;
  31725. if (_skipLocationChange === void 0) { _skipLocationChange = false; }
  31726. this._currentInstruction = instruction;
  31727. var next = _resolveToTrue;
  31728. if (lang_1.isPresent(this._outlet)) {
  31729. var componentInstruction = instruction.component;
  31730. if (componentInstruction.reuse) {
  31731. next = this._outlet.reuse(componentInstruction);
  31732. }
  31733. else {
  31734. next =
  31735. this.deactivate(instruction).then(function (_) { return _this._outlet.activate(componentInstruction); });
  31736. }
  31737. if (lang_1.isPresent(instruction.child)) {
  31738. next = next.then(function (_) {
  31739. if (lang_1.isPresent(_this._childRouter)) {
  31740. return _this._childRouter.commit(instruction.child);
  31741. }
  31742. });
  31743. }
  31744. }
  31745. var promises = [];
  31746. this._auxRouters.forEach(function (router, name) {
  31747. if (lang_1.isPresent(instruction.auxInstruction[name])) {
  31748. promises.push(router.commit(instruction.auxInstruction[name]));
  31749. }
  31750. });
  31751. return next.then(function (_) { return async_1.PromiseWrapper.all(promises); });
  31752. };
  31753. /** @internal */
  31754. Router.prototype._startNavigating = function () { this.navigating = true; };
  31755. /** @internal */
  31756. Router.prototype._finishNavigating = function () { this.navigating = false; };
  31757. /**
  31758. * Subscribe to URL updates from the router
  31759. */
  31760. Router.prototype.subscribe = function (onNext) {
  31761. return async_1.ObservableWrapper.subscribe(this._subject, onNext);
  31762. };
  31763. /**
  31764. * Removes the contents of this router's outlet and all descendant outlets
  31765. */
  31766. Router.prototype.deactivate = function (instruction) {
  31767. var _this = this;
  31768. var childInstruction = null;
  31769. var componentInstruction = null;
  31770. if (lang_1.isPresent(instruction)) {
  31771. childInstruction = instruction.child;
  31772. componentInstruction = instruction.component;
  31773. }
  31774. var next = _resolveToTrue;
  31775. if (lang_1.isPresent(this._childRouter)) {
  31776. next = this._childRouter.deactivate(childInstruction);
  31777. }
  31778. if (lang_1.isPresent(this._outlet)) {
  31779. next = next.then(function (_) { return _this._outlet.deactivate(componentInstruction); });
  31780. }
  31781. // TODO: handle aux routes
  31782. return next;
  31783. };
  31784. /**
  31785. * Given a URL, returns an instruction representing the component graph
  31786. */
  31787. Router.prototype.recognize = function (url) {
  31788. var ancestorComponents = this._getAncestorInstructions();
  31789. return this.registry.recognize(url, ancestorComponents);
  31790. };
  31791. Router.prototype._getAncestorInstructions = function () {
  31792. var ancestorComponents = [];
  31793. var ancestorRouter = this;
  31794. while (lang_1.isPresent(ancestorRouter.parent) &&
  31795. lang_1.isPresent(ancestorRouter.parent._currentInstruction)) {
  31796. ancestorRouter = ancestorRouter.parent;
  31797. ancestorComponents.unshift(ancestorRouter._currentInstruction);
  31798. }
  31799. return ancestorComponents;
  31800. };
  31801. /**
  31802. * Navigates to either the last URL successfully navigated to, or the last URL requested if the
  31803. * router has yet to successfully navigate.
  31804. */
  31805. Router.prototype.renavigate = function () {
  31806. if (lang_1.isBlank(this.lastNavigationAttempt)) {
  31807. return this._currentNavigation;
  31808. }
  31809. return this.navigateByUrl(this.lastNavigationAttempt);
  31810. };
  31811. /**
  31812. * Generate an `Instruction` based on the provided Route Link DSL.
  31813. */
  31814. Router.prototype.generate = function (linkParams) {
  31815. var ancestorInstructions = this._getAncestorInstructions();
  31816. return this.registry.generate(linkParams, ancestorInstructions);
  31817. };
  31818. return Router;
  31819. })();
  31820. exports.Router = Router;
  31821. var RootRouter = (function (_super) {
  31822. __extends(RootRouter, _super);
  31823. function RootRouter(registry, location, primaryComponent) {
  31824. var _this = this;
  31825. _super.call(this, registry, null, primaryComponent);
  31826. this._location = location;
  31827. this._locationSub = this._location.subscribe(function (change) {
  31828. // we call recognize ourselves
  31829. _this.recognize(change['url'])
  31830. .then(function (instruction) {
  31831. _this.navigateByInstruction(instruction, lang_1.isPresent(change['pop']))
  31832. .then(function (_) {
  31833. // this is a popstate event; no need to change the URL
  31834. if (lang_1.isPresent(change['pop']) && change['type'] != 'hashchange') {
  31835. return;
  31836. }
  31837. var emitPath = instruction.toUrlPath();
  31838. var emitQuery = instruction.toUrlQuery();
  31839. if (emitPath.length > 0) {
  31840. emitPath = '/' + emitPath;
  31841. }
  31842. // Because we've opted to use All hashchange events occur outside Angular.
  31843. // However, apps that are migrating might have hash links that operate outside
  31844. // angular to which routing must respond.
  31845. // To support these cases where we respond to hashchanges and redirect as a
  31846. // result, we need to replace the top item on the stack.
  31847. if (change['type'] == 'hashchange') {
  31848. if (instruction.toRootUrl() != _this._location.path()) {
  31849. _this._location.replaceState(emitPath, emitQuery);
  31850. }
  31851. }
  31852. else {
  31853. _this._location.go(emitPath, emitQuery);
  31854. }
  31855. });
  31856. });
  31857. });
  31858. this.registry.configFromComponent(primaryComponent);
  31859. this.navigateByUrl(location.path());
  31860. }
  31861. RootRouter.prototype.commit = function (instruction, _skipLocationChange) {
  31862. var _this = this;
  31863. if (_skipLocationChange === void 0) { _skipLocationChange = false; }
  31864. var emitPath = instruction.toUrlPath();
  31865. var emitQuery = instruction.toUrlQuery();
  31866. if (emitPath.length > 0) {
  31867. emitPath = '/' + emitPath;
  31868. }
  31869. var promise = _super.prototype.commit.call(this, instruction);
  31870. if (!_skipLocationChange) {
  31871. promise = promise.then(function (_) { _this._location.go(emitPath, emitQuery); });
  31872. }
  31873. return promise;
  31874. };
  31875. RootRouter.prototype.dispose = function () {
  31876. if (lang_1.isPresent(this._locationSub)) {
  31877. async_1.ObservableWrapper.dispose(this._locationSub);
  31878. this._locationSub = null;
  31879. }
  31880. };
  31881. RootRouter = __decorate([
  31882. core_1.Injectable(),
  31883. __param(2, core_1.Inject(route_registry_1.ROUTER_PRIMARY_COMPONENT)),
  31884. __metadata('design:paramtypes', [route_registry_1.RouteRegistry, location_1.Location, lang_1.Type])
  31885. ], RootRouter);
  31886. return RootRouter;
  31887. })(Router);
  31888. exports.RootRouter = RootRouter;
  31889. var ChildRouter = (function (_super) {
  31890. __extends(ChildRouter, _super);
  31891. function ChildRouter(parent, hostComponent) {
  31892. _super.call(this, parent.registry, parent, hostComponent);
  31893. this.parent = parent;
  31894. }
  31895. ChildRouter.prototype.navigateByUrl = function (url, _skipLocationChange) {
  31896. if (_skipLocationChange === void 0) { _skipLocationChange = false; }
  31897. // Delegate navigation to the root router
  31898. return this.parent.navigateByUrl(url, _skipLocationChange);
  31899. };
  31900. ChildRouter.prototype.navigateByInstruction = function (instruction, _skipLocationChange) {
  31901. if (_skipLocationChange === void 0) { _skipLocationChange = false; }
  31902. // Delegate navigation to the root router
  31903. return this.parent.navigateByInstruction(instruction, _skipLocationChange);
  31904. };
  31905. return ChildRouter;
  31906. })(Router);
  31907. function canActivateOne(nextInstruction, prevInstruction) {
  31908. var next = _resolveToTrue;
  31909. if (lang_1.isPresent(nextInstruction.child)) {
  31910. next = canActivateOne(nextInstruction.child, lang_1.isPresent(prevInstruction) ? prevInstruction.child : null);
  31911. }
  31912. return next.then(function (result) {
  31913. if (result == false) {
  31914. return false;
  31915. }
  31916. if (nextInstruction.component.reuse) {
  31917. return true;
  31918. }
  31919. var hook = route_lifecycle_reflector_1.getCanActivateHook(nextInstruction.component.componentType);
  31920. if (lang_1.isPresent(hook)) {
  31921. return hook(nextInstruction.component, lang_1.isPresent(prevInstruction) ? prevInstruction.component : null);
  31922. }
  31923. return true;
  31924. });
  31925. }
  31926. /***/ },
  31927. /* 226 */
  31928. /***/ function(module, exports, __webpack_require__) {
  31929. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  31930. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  31931. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  31932. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  31933. return c > 3 && r && Object.defineProperty(target, key, r), r;
  31934. };
  31935. var __metadata = (this && this.__metadata) || function (k, v) {
  31936. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  31937. };
  31938. var __param = (this && this.__param) || function (paramIndex, decorator) {
  31939. return function (target, key) { decorator(target, key, paramIndex); }
  31940. };
  31941. var collection_1 = __webpack_require__(12);
  31942. var async_1 = __webpack_require__(60);
  31943. var lang_1 = __webpack_require__(5);
  31944. var exceptions_1 = __webpack_require__(14);
  31945. var reflection_1 = __webpack_require__(16);
  31946. var core_1 = __webpack_require__(2);
  31947. var route_config_impl_1 = __webpack_require__(227);
  31948. var route_recognizer_1 = __webpack_require__(228);
  31949. var component_recognizer_1 = __webpack_require__(232);
  31950. var instruction_1 = __webpack_require__(229);
  31951. var route_config_nomalizer_1 = __webpack_require__(235);
  31952. var url_parser_1 = __webpack_require__(231);
  31953. var _resolveToNull = async_1.PromiseWrapper.resolve(null);
  31954. /**
  31955. * Token used to bind the component with the top-level {@link RouteConfig}s for the
  31956. * application.
  31957. *
  31958. * ### Example ([live demo](http://plnkr.co/edit/iRUP8B5OUbxCWQ3AcIDm))
  31959. *
  31960. * ```
  31961. * import {Component} from 'angular2/core';
  31962. * import {
  31963. * ROUTER_DIRECTIVES,
  31964. * ROUTER_PROVIDERS,
  31965. * RouteConfig
  31966. * } from 'angular2/router';
  31967. *
  31968. * @Component({directives: [ROUTER_DIRECTIVES]})
  31969. * @RouteConfig([
  31970. * {...},
  31971. * ])
  31972. * class AppCmp {
  31973. * // ...
  31974. * }
  31975. *
  31976. * bootstrap(AppCmp, [ROUTER_PROVIDERS]);
  31977. * ```
  31978. */
  31979. exports.ROUTER_PRIMARY_COMPONENT = lang_1.CONST_EXPR(new core_1.OpaqueToken('RouterPrimaryComponent'));
  31980. /**
  31981. * The RouteRegistry holds route configurations for each component in an Angular app.
  31982. * It is responsible for creating Instructions from URLs, and generating URLs based on route and
  31983. * parameters.
  31984. */
  31985. var RouteRegistry = (function () {
  31986. function RouteRegistry(_rootComponent) {
  31987. this._rootComponent = _rootComponent;
  31988. this._rules = new collection_1.Map();
  31989. }
  31990. /**
  31991. * Given a component and a configuration object, add the route to this registry
  31992. */
  31993. RouteRegistry.prototype.config = function (parentComponent, config) {
  31994. config = route_config_nomalizer_1.normalizeRouteConfig(config, this);
  31995. // this is here because Dart type guard reasons
  31996. if (config instanceof route_config_impl_1.Route) {
  31997. route_config_nomalizer_1.assertComponentExists(config.component, config.path);
  31998. }
  31999. else if (config instanceof route_config_impl_1.AuxRoute) {
  32000. route_config_nomalizer_1.assertComponentExists(config.component, config.path);
  32001. }
  32002. var recognizer = this._rules.get(parentComponent);
  32003. if (lang_1.isBlank(recognizer)) {
  32004. recognizer = new component_recognizer_1.ComponentRecognizer();
  32005. this._rules.set(parentComponent, recognizer);
  32006. }
  32007. var terminal = recognizer.config(config);
  32008. if (config instanceof route_config_impl_1.Route) {
  32009. if (terminal) {
  32010. assertTerminalComponent(config.component, config.path);
  32011. }
  32012. else {
  32013. this.configFromComponent(config.component);
  32014. }
  32015. }
  32016. };
  32017. /**
  32018. * Reads the annotations of a component and configures the registry based on them
  32019. */
  32020. RouteRegistry.prototype.configFromComponent = function (component) {
  32021. var _this = this;
  32022. if (!lang_1.isType(component)) {
  32023. return;
  32024. }
  32025. // Don't read the annotations from a type more than once –
  32026. // this prevents an infinite loop if a component routes recursively.
  32027. if (this._rules.has(component)) {
  32028. return;
  32029. }
  32030. var annotations = reflection_1.reflector.annotations(component);
  32031. if (lang_1.isPresent(annotations)) {
  32032. for (var i = 0; i < annotations.length; i++) {
  32033. var annotation = annotations[i];
  32034. if (annotation instanceof route_config_impl_1.RouteConfig) {
  32035. var routeCfgs = annotation.configs;
  32036. routeCfgs.forEach(function (config) { return _this.config(component, config); });
  32037. }
  32038. }
  32039. }
  32040. };
  32041. /**
  32042. * Given a URL and a parent component, return the most specific instruction for navigating
  32043. * the application into the state specified by the url
  32044. */
  32045. RouteRegistry.prototype.recognize = function (url, ancestorInstructions) {
  32046. var parsedUrl = url_parser_1.parser.parse(url);
  32047. return this._recognize(parsedUrl, ancestorInstructions);
  32048. };
  32049. /**
  32050. * Recognizes all parent-child routes, but creates unresolved auxiliary routes
  32051. */
  32052. RouteRegistry.prototype._recognize = function (parsedUrl, ancestorInstructions, _aux) {
  32053. var _this = this;
  32054. if (_aux === void 0) { _aux = false; }
  32055. var parentComponent = ancestorInstructions.length > 0 ?
  32056. ancestorInstructions[ancestorInstructions.length - 1].component.componentType :
  32057. this._rootComponent;
  32058. var componentRecognizer = this._rules.get(parentComponent);
  32059. if (lang_1.isBlank(componentRecognizer)) {
  32060. return _resolveToNull;
  32061. }
  32062. // Matches some beginning part of the given URL
  32063. var possibleMatches = _aux ? componentRecognizer.recognizeAuxiliary(parsedUrl) :
  32064. componentRecognizer.recognize(parsedUrl);
  32065. var matchPromises = possibleMatches.map(function (candidate) { return candidate.then(function (candidate) {
  32066. if (candidate instanceof route_recognizer_1.PathMatch) {
  32067. var auxParentInstructions = ancestorInstructions.length > 0 ?
  32068. [ancestorInstructions[ancestorInstructions.length - 1]] :
  32069. [];
  32070. var auxInstructions = _this._auxRoutesToUnresolved(candidate.remainingAux, auxParentInstructions);
  32071. var instruction = new instruction_1.ResolvedInstruction(candidate.instruction, null, auxInstructions);
  32072. if (candidate.instruction.terminal) {
  32073. return instruction;
  32074. }
  32075. var newAncestorComponents = ancestorInstructions.concat([instruction]);
  32076. return _this._recognize(candidate.remaining, newAncestorComponents)
  32077. .then(function (childInstruction) {
  32078. if (lang_1.isBlank(childInstruction)) {
  32079. return null;
  32080. }
  32081. // redirect instructions are already absolute
  32082. if (childInstruction instanceof instruction_1.RedirectInstruction) {
  32083. return childInstruction;
  32084. }
  32085. instruction.child = childInstruction;
  32086. return instruction;
  32087. });
  32088. }
  32089. if (candidate instanceof route_recognizer_1.RedirectMatch) {
  32090. var instruction = _this.generate(candidate.redirectTo, ancestorInstructions);
  32091. return new instruction_1.RedirectInstruction(instruction.component, instruction.child, instruction.auxInstruction);
  32092. }
  32093. }); });
  32094. if ((lang_1.isBlank(parsedUrl) || parsedUrl.path == '') && possibleMatches.length == 0) {
  32095. return async_1.PromiseWrapper.resolve(this.generateDefault(parentComponent));
  32096. }
  32097. return async_1.PromiseWrapper.all(matchPromises).then(mostSpecific);
  32098. };
  32099. RouteRegistry.prototype._auxRoutesToUnresolved = function (auxRoutes, parentInstructions) {
  32100. var _this = this;
  32101. var unresolvedAuxInstructions = {};
  32102. auxRoutes.forEach(function (auxUrl) {
  32103. unresolvedAuxInstructions[auxUrl.path] = new instruction_1.UnresolvedInstruction(function () { return _this._recognize(auxUrl, parentInstructions, true); });
  32104. });
  32105. return unresolvedAuxInstructions;
  32106. };
  32107. /**
  32108. * Given a normalized list with component names and params like: `['user', {id: 3 }]`
  32109. * generates a url with a leading slash relative to the provided `parentComponent`.
  32110. *
  32111. * If the optional param `_aux` is `true`, then we generate starting at an auxiliary
  32112. * route boundary.
  32113. */
  32114. RouteRegistry.prototype.generate = function (linkParams, ancestorInstructions, _aux) {
  32115. if (_aux === void 0) { _aux = false; }
  32116. var normalizedLinkParams = splitAndFlattenLinkParams(linkParams);
  32117. var first = collection_1.ListWrapper.first(normalizedLinkParams);
  32118. var rest = collection_1.ListWrapper.slice(normalizedLinkParams, 1);
  32119. // The first segment should be either '.' (generate from parent) or '' (generate from root).
  32120. // When we normalize above, we strip all the slashes, './' becomes '.' and '/' becomes ''.
  32121. if (first == '') {
  32122. ancestorInstructions = [];
  32123. }
  32124. else if (first == '..') {
  32125. // we already captured the first instance of "..", so we need to pop off an ancestor
  32126. ancestorInstructions.pop();
  32127. while (collection_1.ListWrapper.first(rest) == '..') {
  32128. rest = collection_1.ListWrapper.slice(rest, 1);
  32129. ancestorInstructions.pop();
  32130. if (ancestorInstructions.length <= 0) {
  32131. throw new exceptions_1.BaseException("Link \"" + collection_1.ListWrapper.toJSON(linkParams) + "\" has too many \"../\" segments.");
  32132. }
  32133. }
  32134. }
  32135. else if (first != '.') {
  32136. var parentComponent = this._rootComponent;
  32137. var grandparentComponent = null;
  32138. if (ancestorInstructions.length > 1) {
  32139. parentComponent =
  32140. ancestorInstructions[ancestorInstructions.length - 1].component.componentType;
  32141. grandparentComponent =
  32142. ancestorInstructions[ancestorInstructions.length - 2].component.componentType;
  32143. }
  32144. else if (ancestorInstructions.length == 1) {
  32145. parentComponent = ancestorInstructions[0].component.componentType;
  32146. grandparentComponent = this._rootComponent;
  32147. }
  32148. // For a link with no leading `./`, `/`, or `../`, we look for a sibling and child.
  32149. // If both exist, we throw. Otherwise, we prefer whichever exists.
  32150. var childRouteExists = this.hasRoute(first, parentComponent);
  32151. var parentRouteExists = lang_1.isPresent(grandparentComponent) && this.hasRoute(first, grandparentComponent);
  32152. if (parentRouteExists && childRouteExists) {
  32153. var msg = "Link \"" + collection_1.ListWrapper.toJSON(linkParams) + "\" is ambiguous, use \"./\" or \"../\" to disambiguate.";
  32154. throw new exceptions_1.BaseException(msg);
  32155. }
  32156. if (parentRouteExists) {
  32157. ancestorInstructions.pop();
  32158. }
  32159. rest = linkParams;
  32160. }
  32161. if (rest[rest.length - 1] == '') {
  32162. rest.pop();
  32163. }
  32164. if (rest.length < 1) {
  32165. var msg = "Link \"" + collection_1.ListWrapper.toJSON(linkParams) + "\" must include a route name.";
  32166. throw new exceptions_1.BaseException(msg);
  32167. }
  32168. var generatedInstruction = this._generate(rest, ancestorInstructions, _aux);
  32169. for (var i = ancestorInstructions.length - 1; i >= 0; i--) {
  32170. var ancestorInstruction = ancestorInstructions[i];
  32171. generatedInstruction = ancestorInstruction.replaceChild(generatedInstruction);
  32172. }
  32173. return generatedInstruction;
  32174. };
  32175. /*
  32176. * Internal helper that does not make any assertions about the beginning of the link DSL
  32177. */
  32178. RouteRegistry.prototype._generate = function (linkParams, ancestorInstructions, _aux) {
  32179. var _this = this;
  32180. if (_aux === void 0) { _aux = false; }
  32181. var parentComponent = ancestorInstructions.length > 0 ?
  32182. ancestorInstructions[ancestorInstructions.length - 1].component.componentType :
  32183. this._rootComponent;
  32184. if (linkParams.length == 0) {
  32185. return this.generateDefault(parentComponent);
  32186. }
  32187. var linkIndex = 0;
  32188. var routeName = linkParams[linkIndex];
  32189. if (!lang_1.isString(routeName)) {
  32190. throw new exceptions_1.BaseException("Unexpected segment \"" + routeName + "\" in link DSL. Expected a string.");
  32191. }
  32192. else if (routeName == '' || routeName == '.' || routeName == '..') {
  32193. throw new exceptions_1.BaseException("\"" + routeName + "/\" is only allowed at the beginning of a link DSL.");
  32194. }
  32195. var params = {};
  32196. if (linkIndex + 1 < linkParams.length) {
  32197. var nextSegment_1 = linkParams[linkIndex + 1];
  32198. if (lang_1.isStringMap(nextSegment_1) && !lang_1.isArray(nextSegment_1)) {
  32199. params = nextSegment_1;
  32200. linkIndex += 1;
  32201. }
  32202. }
  32203. var auxInstructions = {};
  32204. var nextSegment;
  32205. while (linkIndex + 1 < linkParams.length && lang_1.isArray(nextSegment = linkParams[linkIndex + 1])) {
  32206. var auxParentInstruction = ancestorInstructions.length > 0 ?
  32207. [ancestorInstructions[ancestorInstructions.length - 1]] :
  32208. [];
  32209. var auxInstruction = this._generate(nextSegment, auxParentInstruction, true);
  32210. // TODO: this will not work for aux routes with parameters or multiple segments
  32211. auxInstructions[auxInstruction.component.urlPath] = auxInstruction;
  32212. linkIndex += 1;
  32213. }
  32214. var componentRecognizer = this._rules.get(parentComponent);
  32215. if (lang_1.isBlank(componentRecognizer)) {
  32216. throw new exceptions_1.BaseException("Component \"" + lang_1.getTypeNameForDebugging(parentComponent) + "\" has no route config.");
  32217. }
  32218. var routeRecognizer = (_aux ? componentRecognizer.auxNames : componentRecognizer.names).get(routeName);
  32219. if (!lang_1.isPresent(routeRecognizer)) {
  32220. throw new exceptions_1.BaseException("Component \"" + lang_1.getTypeNameForDebugging(parentComponent) + "\" has no route named \"" + routeName + "\".");
  32221. }
  32222. if (!lang_1.isPresent(routeRecognizer.handler.componentType)) {
  32223. var compInstruction = routeRecognizer.generateComponentPathValues(params);
  32224. return new instruction_1.UnresolvedInstruction(function () {
  32225. return routeRecognizer.handler.resolveComponentType().then(function (_) { return _this._generate(linkParams, ancestorInstructions, _aux); });
  32226. }, compInstruction['urlPath'], compInstruction['urlParams']);
  32227. }
  32228. var componentInstruction = _aux ? componentRecognizer.generateAuxiliary(routeName, params) :
  32229. componentRecognizer.generate(routeName, params);
  32230. var remaining = linkParams.slice(linkIndex + 1);
  32231. var instruction = new instruction_1.ResolvedInstruction(componentInstruction, null, auxInstructions);
  32232. // the component is sync
  32233. if (lang_1.isPresent(componentInstruction.componentType)) {
  32234. var childInstruction = null;
  32235. if (linkIndex + 1 < linkParams.length) {
  32236. var childAncestorComponents = ancestorInstructions.concat([instruction]);
  32237. childInstruction = this._generate(remaining, childAncestorComponents);
  32238. }
  32239. else if (!componentInstruction.terminal) {
  32240. // ... look for defaults
  32241. childInstruction = this.generateDefault(componentInstruction.componentType);
  32242. if (lang_1.isBlank(childInstruction)) {
  32243. throw new exceptions_1.BaseException("Link \"" + collection_1.ListWrapper.toJSON(linkParams) + "\" does not resolve to a terminal instruction.");
  32244. }
  32245. }
  32246. instruction.child = childInstruction;
  32247. }
  32248. return instruction;
  32249. };
  32250. RouteRegistry.prototype.hasRoute = function (name, parentComponent) {
  32251. var componentRecognizer = this._rules.get(parentComponent);
  32252. if (lang_1.isBlank(componentRecognizer)) {
  32253. return false;
  32254. }
  32255. return componentRecognizer.hasRoute(name);
  32256. };
  32257. RouteRegistry.prototype.generateDefault = function (componentCursor) {
  32258. var _this = this;
  32259. if (lang_1.isBlank(componentCursor)) {
  32260. return null;
  32261. }
  32262. var componentRecognizer = this._rules.get(componentCursor);
  32263. if (lang_1.isBlank(componentRecognizer) || lang_1.isBlank(componentRecognizer.defaultRoute)) {
  32264. return null;
  32265. }
  32266. var defaultChild = null;
  32267. if (lang_1.isPresent(componentRecognizer.defaultRoute.handler.componentType)) {
  32268. var componentInstruction = componentRecognizer.defaultRoute.generate({});
  32269. if (!componentRecognizer.defaultRoute.terminal) {
  32270. defaultChild = this.generateDefault(componentRecognizer.defaultRoute.handler.componentType);
  32271. }
  32272. return new instruction_1.DefaultInstruction(componentInstruction, defaultChild);
  32273. }
  32274. return new instruction_1.UnresolvedInstruction(function () {
  32275. return componentRecognizer.defaultRoute.handler.resolveComponentType().then(function (_) { return _this.generateDefault(componentCursor); });
  32276. });
  32277. };
  32278. RouteRegistry = __decorate([
  32279. core_1.Injectable(),
  32280. __param(0, core_1.Inject(exports.ROUTER_PRIMARY_COMPONENT)),
  32281. __metadata('design:paramtypes', [lang_1.Type])
  32282. ], RouteRegistry);
  32283. return RouteRegistry;
  32284. })();
  32285. exports.RouteRegistry = RouteRegistry;
  32286. /*
  32287. * Given: ['/a/b', {c: 2}]
  32288. * Returns: ['', 'a', 'b', {c: 2}]
  32289. */
  32290. function splitAndFlattenLinkParams(linkParams) {
  32291. return linkParams.reduce(function (accumulation, item) {
  32292. if (lang_1.isString(item)) {
  32293. var strItem = item;
  32294. return accumulation.concat(strItem.split('/'));
  32295. }
  32296. accumulation.push(item);
  32297. return accumulation;
  32298. }, []);
  32299. }
  32300. /*
  32301. * Given a list of instructions, returns the most specific instruction
  32302. */
  32303. function mostSpecific(instructions) {
  32304. return collection_1.ListWrapper.maximum(instructions, function (instruction) { return instruction.specificity; });
  32305. }
  32306. function assertTerminalComponent(component, path) {
  32307. if (!lang_1.isType(component)) {
  32308. return;
  32309. }
  32310. var annotations = reflection_1.reflector.annotations(component);
  32311. if (lang_1.isPresent(annotations)) {
  32312. for (var i = 0; i < annotations.length; i++) {
  32313. var annotation = annotations[i];
  32314. if (annotation instanceof route_config_impl_1.RouteConfig) {
  32315. throw new exceptions_1.BaseException("Child routes are not allowed for \"" + path + "\". Use \"...\" on the parent's route path.");
  32316. }
  32317. }
  32318. }
  32319. }
  32320. /***/ },
  32321. /* 227 */
  32322. /***/ function(module, exports, __webpack_require__) {
  32323. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  32324. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  32325. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  32326. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  32327. return c > 3 && r && Object.defineProperty(target, key, r), r;
  32328. };
  32329. var __metadata = (this && this.__metadata) || function (k, v) {
  32330. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  32331. };
  32332. var lang_1 = __webpack_require__(5);
  32333. /**
  32334. * The `RouteConfig` decorator defines routes for a given component.
  32335. *
  32336. * It takes an array of {@link RouteDefinition}s.
  32337. */
  32338. var RouteConfig = (function () {
  32339. function RouteConfig(configs) {
  32340. this.configs = configs;
  32341. }
  32342. RouteConfig = __decorate([
  32343. lang_1.CONST(),
  32344. __metadata('design:paramtypes', [Array])
  32345. ], RouteConfig);
  32346. return RouteConfig;
  32347. })();
  32348. exports.RouteConfig = RouteConfig;
  32349. /**
  32350. * `Route` is a type of {@link RouteDefinition} used to route a path to a component.
  32351. *
  32352. * It has the following properties:
  32353. * - `path` is a string that uses the route matcher DSL.
  32354. * - `component` a component type.
  32355. * - `name` is an optional `CamelCase` string representing the name of the route.
  32356. * - `data` is an optional property of any type representing arbitrary route metadata for the given
  32357. * route. It is injectable via {@link RouteData}.
  32358. * - `useAsDefault` is a boolean value. If `true`, the child route will be navigated to if no child
  32359. * route is specified during the navigation.
  32360. *
  32361. * ### Example
  32362. * ```
  32363. * import {RouteConfig} from 'angular2/router';
  32364. *
  32365. * @RouteConfig([
  32366. * {path: '/home', component: HomeCmp, name: 'HomeCmp' }
  32367. * ])
  32368. * class MyApp {}
  32369. * ```
  32370. */
  32371. var Route = (function () {
  32372. function Route(_a) {
  32373. var path = _a.path, component = _a.component, name = _a.name, data = _a.data, useAsDefault = _a.useAsDefault;
  32374. // added next three properties to work around https://github.com/Microsoft/TypeScript/issues/4107
  32375. this.aux = null;
  32376. this.loader = null;
  32377. this.redirectTo = null;
  32378. this.path = path;
  32379. this.component = component;
  32380. this.name = name;
  32381. this.data = data;
  32382. this.useAsDefault = useAsDefault;
  32383. }
  32384. Route = __decorate([
  32385. lang_1.CONST(),
  32386. __metadata('design:paramtypes', [Object])
  32387. ], Route);
  32388. return Route;
  32389. })();
  32390. exports.Route = Route;
  32391. /**
  32392. * `AuxRoute` is a type of {@link RouteDefinition} used to define an auxiliary route.
  32393. *
  32394. * It takes an object with the following properties:
  32395. * - `path` is a string that uses the route matcher DSL.
  32396. * - `component` a component type.
  32397. * - `name` is an optional `CamelCase` string representing the name of the route.
  32398. * - `data` is an optional property of any type representing arbitrary route metadata for the given
  32399. * route. It is injectable via {@link RouteData}.
  32400. *
  32401. * ### Example
  32402. * ```
  32403. * import {RouteConfig, AuxRoute} from 'angular2/router';
  32404. *
  32405. * @RouteConfig([
  32406. * new AuxRoute({path: '/home', component: HomeCmp})
  32407. * ])
  32408. * class MyApp {}
  32409. * ```
  32410. */
  32411. var AuxRoute = (function () {
  32412. function AuxRoute(_a) {
  32413. var path = _a.path, component = _a.component, name = _a.name;
  32414. this.data = null;
  32415. // added next three properties to work around https://github.com/Microsoft/TypeScript/issues/4107
  32416. this.aux = null;
  32417. this.loader = null;
  32418. this.redirectTo = null;
  32419. this.useAsDefault = false;
  32420. this.path = path;
  32421. this.component = component;
  32422. this.name = name;
  32423. }
  32424. AuxRoute = __decorate([
  32425. lang_1.CONST(),
  32426. __metadata('design:paramtypes', [Object])
  32427. ], AuxRoute);
  32428. return AuxRoute;
  32429. })();
  32430. exports.AuxRoute = AuxRoute;
  32431. /**
  32432. * `AsyncRoute` is a type of {@link RouteDefinition} used to route a path to an asynchronously
  32433. * loaded component.
  32434. *
  32435. * It has the following properties:
  32436. * - `path` is a string that uses the route matcher DSL.
  32437. * - `loader` is a function that returns a promise that resolves to a component.
  32438. * - `name` is an optional `CamelCase` string representing the name of the route.
  32439. * - `data` is an optional property of any type representing arbitrary route metadata for the given
  32440. * route. It is injectable via {@link RouteData}.
  32441. * - `useAsDefault` is a boolean value. If `true`, the child route will be navigated to if no child
  32442. * route is specified during the navigation.
  32443. *
  32444. * ### Example
  32445. * ```
  32446. * import {RouteConfig} from 'angular2/router';
  32447. *
  32448. * @RouteConfig([
  32449. * {path: '/home', loader: () => Promise.resolve(MyLoadedCmp), name: 'MyLoadedCmp'}
  32450. * ])
  32451. * class MyApp {}
  32452. * ```
  32453. */
  32454. var AsyncRoute = (function () {
  32455. function AsyncRoute(_a) {
  32456. var path = _a.path, loader = _a.loader, name = _a.name, data = _a.data, useAsDefault = _a.useAsDefault;
  32457. this.aux = null;
  32458. this.path = path;
  32459. this.loader = loader;
  32460. this.name = name;
  32461. this.data = data;
  32462. this.useAsDefault = useAsDefault;
  32463. }
  32464. AsyncRoute = __decorate([
  32465. lang_1.CONST(),
  32466. __metadata('design:paramtypes', [Object])
  32467. ], AsyncRoute);
  32468. return AsyncRoute;
  32469. })();
  32470. exports.AsyncRoute = AsyncRoute;
  32471. /**
  32472. * `Redirect` is a type of {@link RouteDefinition} used to route a path to a canonical route.
  32473. *
  32474. * It has the following properties:
  32475. * - `path` is a string that uses the route matcher DSL.
  32476. * - `redirectTo` is an array representing the link DSL.
  32477. *
  32478. * Note that redirects **do not** affect how links are generated. For that, see the `useAsDefault`
  32479. * option.
  32480. *
  32481. * ### Example
  32482. * ```
  32483. * import {RouteConfig} from 'angular2/router';
  32484. *
  32485. * @RouteConfig([
  32486. * {path: '/', redirectTo: ['/Home'] },
  32487. * {path: '/home', component: HomeCmp, name: 'Home'}
  32488. * ])
  32489. * class MyApp {}
  32490. * ```
  32491. */
  32492. var Redirect = (function () {
  32493. function Redirect(_a) {
  32494. var path = _a.path, redirectTo = _a.redirectTo;
  32495. this.name = null;
  32496. // added next three properties to work around https://github.com/Microsoft/TypeScript/issues/4107
  32497. this.loader = null;
  32498. this.data = null;
  32499. this.aux = null;
  32500. this.useAsDefault = false;
  32501. this.path = path;
  32502. this.redirectTo = redirectTo;
  32503. }
  32504. Redirect = __decorate([
  32505. lang_1.CONST(),
  32506. __metadata('design:paramtypes', [Object])
  32507. ], Redirect);
  32508. return Redirect;
  32509. })();
  32510. exports.Redirect = Redirect;
  32511. /***/ },
  32512. /* 228 */
  32513. /***/ function(module, exports, __webpack_require__) {
  32514. var __extends = (this && this.__extends) || function (d, b) {
  32515. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  32516. function __() { this.constructor = d; }
  32517. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  32518. };
  32519. var lang_1 = __webpack_require__(5);
  32520. var exceptions_1 = __webpack_require__(14);
  32521. var promise_1 = __webpack_require__(61);
  32522. var collection_1 = __webpack_require__(12);
  32523. var instruction_1 = __webpack_require__(229);
  32524. var path_recognizer_1 = __webpack_require__(230);
  32525. var RouteMatch = (function () {
  32526. function RouteMatch() {
  32527. }
  32528. return RouteMatch;
  32529. })();
  32530. exports.RouteMatch = RouteMatch;
  32531. var PathMatch = (function (_super) {
  32532. __extends(PathMatch, _super);
  32533. function PathMatch(instruction, remaining, remainingAux) {
  32534. _super.call(this);
  32535. this.instruction = instruction;
  32536. this.remaining = remaining;
  32537. this.remainingAux = remainingAux;
  32538. }
  32539. return PathMatch;
  32540. })(RouteMatch);
  32541. exports.PathMatch = PathMatch;
  32542. var RedirectMatch = (function (_super) {
  32543. __extends(RedirectMatch, _super);
  32544. function RedirectMatch(redirectTo, specificity) {
  32545. _super.call(this);
  32546. this.redirectTo = redirectTo;
  32547. this.specificity = specificity;
  32548. }
  32549. return RedirectMatch;
  32550. })(RouteMatch);
  32551. exports.RedirectMatch = RedirectMatch;
  32552. var RedirectRecognizer = (function () {
  32553. function RedirectRecognizer(path, redirectTo) {
  32554. this.path = path;
  32555. this.redirectTo = redirectTo;
  32556. this._pathRecognizer = new path_recognizer_1.PathRecognizer(path);
  32557. this.hash = this._pathRecognizer.hash;
  32558. }
  32559. /**
  32560. * Returns `null` or a `ParsedUrl` representing the new path to match
  32561. */
  32562. RedirectRecognizer.prototype.recognize = function (beginningSegment) {
  32563. var match = null;
  32564. if (lang_1.isPresent(this._pathRecognizer.recognize(beginningSegment))) {
  32565. match = new RedirectMatch(this.redirectTo, this._pathRecognizer.specificity);
  32566. }
  32567. return promise_1.PromiseWrapper.resolve(match);
  32568. };
  32569. RedirectRecognizer.prototype.generate = function (params) {
  32570. throw new exceptions_1.BaseException("Tried to generate a redirect.");
  32571. };
  32572. return RedirectRecognizer;
  32573. })();
  32574. exports.RedirectRecognizer = RedirectRecognizer;
  32575. // represents something like '/foo/:bar'
  32576. var RouteRecognizer = (function () {
  32577. // TODO: cache component instruction instances by params and by ParsedUrl instance
  32578. function RouteRecognizer(path, handler) {
  32579. this.path = path;
  32580. this.handler = handler;
  32581. this.terminal = true;
  32582. this._cache = new collection_1.Map();
  32583. this._pathRecognizer = new path_recognizer_1.PathRecognizer(path);
  32584. this.specificity = this._pathRecognizer.specificity;
  32585. this.hash = this._pathRecognizer.hash;
  32586. this.terminal = this._pathRecognizer.terminal;
  32587. }
  32588. RouteRecognizer.prototype.recognize = function (beginningSegment) {
  32589. var _this = this;
  32590. var res = this._pathRecognizer.recognize(beginningSegment);
  32591. if (lang_1.isBlank(res)) {
  32592. return null;
  32593. }
  32594. return this.handler.resolveComponentType().then(function (_) {
  32595. var componentInstruction = _this._getInstruction(res['urlPath'], res['urlParams'], res['allParams']);
  32596. return new PathMatch(componentInstruction, res['nextSegment'], res['auxiliary']);
  32597. });
  32598. };
  32599. RouteRecognizer.prototype.generate = function (params) {
  32600. var generated = this._pathRecognizer.generate(params);
  32601. var urlPath = generated['urlPath'];
  32602. var urlParams = generated['urlParams'];
  32603. return this._getInstruction(urlPath, urlParams, params);
  32604. };
  32605. RouteRecognizer.prototype.generateComponentPathValues = function (params) {
  32606. return this._pathRecognizer.generate(params);
  32607. };
  32608. RouteRecognizer.prototype._getInstruction = function (urlPath, urlParams, params) {
  32609. if (lang_1.isBlank(this.handler.componentType)) {
  32610. throw new exceptions_1.BaseException("Tried to get instruction before the type was loaded.");
  32611. }
  32612. var hashKey = urlPath + '?' + urlParams.join('?');
  32613. if (this._cache.has(hashKey)) {
  32614. return this._cache.get(hashKey);
  32615. }
  32616. var instruction = new instruction_1.ComponentInstruction(urlPath, urlParams, this.handler.data, this.handler.componentType, this.terminal, this.specificity, params);
  32617. this._cache.set(hashKey, instruction);
  32618. return instruction;
  32619. };
  32620. return RouteRecognizer;
  32621. })();
  32622. exports.RouteRecognizer = RouteRecognizer;
  32623. /***/ },
  32624. /* 229 */
  32625. /***/ function(module, exports, __webpack_require__) {
  32626. var __extends = (this && this.__extends) || function (d, b) {
  32627. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  32628. function __() { this.constructor = d; }
  32629. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  32630. };
  32631. var collection_1 = __webpack_require__(12);
  32632. var lang_1 = __webpack_require__(5);
  32633. var async_1 = __webpack_require__(60);
  32634. /**
  32635. * `RouteParams` is an immutable map of parameters for the given route
  32636. * based on the url matcher and optional parameters for that route.
  32637. *
  32638. * You can inject `RouteParams` into the constructor of a component to use it.
  32639. *
  32640. * ### Example
  32641. *
  32642. * ```
  32643. * import {Component} from 'angular2/core';
  32644. * import {bootstrap} from 'angular2/platform/browser';
  32645. * import {Router, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from 'angular2/router';
  32646. *
  32647. * @Component({directives: [ROUTER_DIRECTIVES]})
  32648. * @RouteConfig([
  32649. * {path: '/user/:id', component: UserCmp, as: 'UserCmp'},
  32650. * ])
  32651. * class AppCmp {}
  32652. *
  32653. * @Component({ template: 'user: {{id}}' })
  32654. * class UserCmp {
  32655. * id: string;
  32656. * constructor(params: RouteParams) {
  32657. * this.id = params.get('id');
  32658. * }
  32659. * }
  32660. *
  32661. * bootstrap(AppCmp, ROUTER_PROVIDERS);
  32662. * ```
  32663. */
  32664. var RouteParams = (function () {
  32665. function RouteParams(params) {
  32666. this.params = params;
  32667. }
  32668. RouteParams.prototype.get = function (param) { return lang_1.normalizeBlank(collection_1.StringMapWrapper.get(this.params, param)); };
  32669. return RouteParams;
  32670. })();
  32671. exports.RouteParams = RouteParams;
  32672. /**
  32673. * `RouteData` is an immutable map of additional data you can configure in your {@link Route}.
  32674. *
  32675. * You can inject `RouteData` into the constructor of a component to use it.
  32676. *
  32677. * ### Example
  32678. *
  32679. * ```
  32680. * import {Component, View} from 'angular2/core';
  32681. * import {bootstrap} from 'angular2/platform/browser';
  32682. * import {Router, ROUTER_DIRECTIVES, routerBindings, RouteConfig} from 'angular2/router';
  32683. *
  32684. * @Component({...})
  32685. * @View({directives: [ROUTER_DIRECTIVES]})
  32686. * @RouteConfig([
  32687. * {path: '/user/:id', component: UserCmp, as: 'UserCmp', data: {isAdmin: true}},
  32688. * ])
  32689. * class AppCmp {}
  32690. *
  32691. * @Component({...})
  32692. * @View({ template: 'user: {{isAdmin}}' })
  32693. * class UserCmp {
  32694. * string: isAdmin;
  32695. * constructor(data: RouteData) {
  32696. * this.isAdmin = data.get('isAdmin');
  32697. * }
  32698. * }
  32699. *
  32700. * bootstrap(AppCmp, routerBindings(AppCmp));
  32701. * ```
  32702. */
  32703. var RouteData = (function () {
  32704. function RouteData(data) {
  32705. if (data === void 0) { data = lang_1.CONST_EXPR({}); }
  32706. this.data = data;
  32707. }
  32708. RouteData.prototype.get = function (key) { return lang_1.normalizeBlank(collection_1.StringMapWrapper.get(this.data, key)); };
  32709. return RouteData;
  32710. })();
  32711. exports.RouteData = RouteData;
  32712. exports.BLANK_ROUTE_DATA = new RouteData();
  32713. /**
  32714. * `Instruction` is a tree of {@link ComponentInstruction}s with all the information needed
  32715. * to transition each component in the app to a given route, including all auxiliary routes.
  32716. *
  32717. * `Instruction`s can be created using {@link Router#generate}, and can be used to
  32718. * perform route changes with {@link Router#navigateByInstruction}.
  32719. *
  32720. * ### Example
  32721. *
  32722. * ```
  32723. * import {Component} from 'angular2/core';
  32724. * import {bootstrap} from 'angular2/platform/browser';
  32725. * import {Router, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from 'angular2/router';
  32726. *
  32727. * @Component({directives: [ROUTER_DIRECTIVES]})
  32728. * @RouteConfig([
  32729. * {...},
  32730. * ])
  32731. * class AppCmp {
  32732. * constructor(router: Router) {
  32733. * var instruction = router.generate(['/MyRoute']);
  32734. * router.navigateByInstruction(instruction);
  32735. * }
  32736. * }
  32737. *
  32738. * bootstrap(AppCmp, ROUTER_PROVIDERS);
  32739. * ```
  32740. */
  32741. var Instruction = (function () {
  32742. function Instruction() {
  32743. this.auxInstruction = {};
  32744. }
  32745. Object.defineProperty(Instruction.prototype, "urlPath", {
  32746. get: function () { return this.component.urlPath; },
  32747. enumerable: true,
  32748. configurable: true
  32749. });
  32750. Object.defineProperty(Instruction.prototype, "urlParams", {
  32751. get: function () { return this.component.urlParams; },
  32752. enumerable: true,
  32753. configurable: true
  32754. });
  32755. Object.defineProperty(Instruction.prototype, "specificity", {
  32756. get: function () {
  32757. var total = 0;
  32758. if (lang_1.isPresent(this.component)) {
  32759. total += this.component.specificity;
  32760. }
  32761. if (lang_1.isPresent(this.child)) {
  32762. total += this.child.specificity;
  32763. }
  32764. return total;
  32765. },
  32766. enumerable: true,
  32767. configurable: true
  32768. });
  32769. /**
  32770. * converts the instruction into a URL string
  32771. */
  32772. Instruction.prototype.toRootUrl = function () { return this.toUrlPath() + this.toUrlQuery(); };
  32773. /** @internal */
  32774. Instruction.prototype._toNonRootUrl = function () {
  32775. return this._stringifyPathMatrixAuxPrefixed() +
  32776. (lang_1.isPresent(this.child) ? this.child._toNonRootUrl() : '');
  32777. };
  32778. Instruction.prototype.toUrlQuery = function () { return this.urlParams.length > 0 ? ('?' + this.urlParams.join('&')) : ''; };
  32779. /**
  32780. * Returns a new instruction that shares the state of the existing instruction, but with
  32781. * the given child {@link Instruction} replacing the existing child.
  32782. */
  32783. Instruction.prototype.replaceChild = function (child) {
  32784. return new ResolvedInstruction(this.component, child, this.auxInstruction);
  32785. };
  32786. /**
  32787. * If the final URL for the instruction is ``
  32788. */
  32789. Instruction.prototype.toUrlPath = function () {
  32790. return this.urlPath + this._stringifyAux() +
  32791. (lang_1.isPresent(this.child) ? this.child._toNonRootUrl() : '');
  32792. };
  32793. // default instructions override these
  32794. Instruction.prototype.toLinkUrl = function () {
  32795. return this.urlPath + this._stringifyAux() +
  32796. (lang_1.isPresent(this.child) ? this.child._toLinkUrl() : '');
  32797. };
  32798. // this is the non-root version (called recursively)
  32799. /** @internal */
  32800. Instruction.prototype._toLinkUrl = function () {
  32801. return this._stringifyPathMatrixAuxPrefixed() +
  32802. (lang_1.isPresent(this.child) ? this.child._toLinkUrl() : '');
  32803. };
  32804. /** @internal */
  32805. Instruction.prototype._stringifyPathMatrixAuxPrefixed = function () {
  32806. var primary = this._stringifyPathMatrixAux();
  32807. if (primary.length > 0) {
  32808. primary = '/' + primary;
  32809. }
  32810. return primary;
  32811. };
  32812. /** @internal */
  32813. Instruction.prototype._stringifyMatrixParams = function () {
  32814. return this.urlParams.length > 0 ? (';' + this.component.urlParams.join(';')) : '';
  32815. };
  32816. /** @internal */
  32817. Instruction.prototype._stringifyPathMatrixAux = function () {
  32818. if (lang_1.isBlank(this.component)) {
  32819. return '';
  32820. }
  32821. return this.urlPath + this._stringifyMatrixParams() + this._stringifyAux();
  32822. };
  32823. /** @internal */
  32824. Instruction.prototype._stringifyAux = function () {
  32825. var routes = [];
  32826. collection_1.StringMapWrapper.forEach(this.auxInstruction, function (auxInstruction, _) {
  32827. routes.push(auxInstruction._stringifyPathMatrixAux());
  32828. });
  32829. if (routes.length > 0) {
  32830. return '(' + routes.join('//') + ')';
  32831. }
  32832. return '';
  32833. };
  32834. return Instruction;
  32835. })();
  32836. exports.Instruction = Instruction;
  32837. /**
  32838. * a resolved instruction has an outlet instruction for itself, but maybe not for...
  32839. */
  32840. var ResolvedInstruction = (function (_super) {
  32841. __extends(ResolvedInstruction, _super);
  32842. function ResolvedInstruction(component, child, auxInstruction) {
  32843. _super.call(this);
  32844. this.component = component;
  32845. this.child = child;
  32846. this.auxInstruction = auxInstruction;
  32847. }
  32848. ResolvedInstruction.prototype.resolveComponent = function () {
  32849. return async_1.PromiseWrapper.resolve(this.component);
  32850. };
  32851. return ResolvedInstruction;
  32852. })(Instruction);
  32853. exports.ResolvedInstruction = ResolvedInstruction;
  32854. /**
  32855. * Represents a resolved default route
  32856. */
  32857. var DefaultInstruction = (function (_super) {
  32858. __extends(DefaultInstruction, _super);
  32859. function DefaultInstruction(component, child) {
  32860. _super.call(this);
  32861. this.component = component;
  32862. this.child = child;
  32863. }
  32864. DefaultInstruction.prototype.resolveComponent = function () {
  32865. return async_1.PromiseWrapper.resolve(this.component);
  32866. };
  32867. DefaultInstruction.prototype.toLinkUrl = function () { return ''; };
  32868. /** @internal */
  32869. DefaultInstruction.prototype._toLinkUrl = function () { return ''; };
  32870. return DefaultInstruction;
  32871. })(Instruction);
  32872. exports.DefaultInstruction = DefaultInstruction;
  32873. /**
  32874. * Represents a component that may need to do some redirection or lazy loading at a later time.
  32875. */
  32876. var UnresolvedInstruction = (function (_super) {
  32877. __extends(UnresolvedInstruction, _super);
  32878. function UnresolvedInstruction(_resolver, _urlPath, _urlParams) {
  32879. if (_urlPath === void 0) { _urlPath = ''; }
  32880. if (_urlParams === void 0) { _urlParams = lang_1.CONST_EXPR([]); }
  32881. _super.call(this);
  32882. this._resolver = _resolver;
  32883. this._urlPath = _urlPath;
  32884. this._urlParams = _urlParams;
  32885. }
  32886. Object.defineProperty(UnresolvedInstruction.prototype, "urlPath", {
  32887. get: function () {
  32888. if (lang_1.isPresent(this.component)) {
  32889. return this.component.urlPath;
  32890. }
  32891. if (lang_1.isPresent(this._urlPath)) {
  32892. return this._urlPath;
  32893. }
  32894. return '';
  32895. },
  32896. enumerable: true,
  32897. configurable: true
  32898. });
  32899. Object.defineProperty(UnresolvedInstruction.prototype, "urlParams", {
  32900. get: function () {
  32901. if (lang_1.isPresent(this.component)) {
  32902. return this.component.urlParams;
  32903. }
  32904. if (lang_1.isPresent(this._urlParams)) {
  32905. return this._urlParams;
  32906. }
  32907. return [];
  32908. },
  32909. enumerable: true,
  32910. configurable: true
  32911. });
  32912. UnresolvedInstruction.prototype.resolveComponent = function () {
  32913. var _this = this;
  32914. if (lang_1.isPresent(this.component)) {
  32915. return async_1.PromiseWrapper.resolve(this.component);
  32916. }
  32917. return this._resolver().then(function (resolution) {
  32918. _this.child = resolution.child;
  32919. return _this.component = resolution.component;
  32920. });
  32921. };
  32922. return UnresolvedInstruction;
  32923. })(Instruction);
  32924. exports.UnresolvedInstruction = UnresolvedInstruction;
  32925. var RedirectInstruction = (function (_super) {
  32926. __extends(RedirectInstruction, _super);
  32927. function RedirectInstruction(component, child, auxInstruction) {
  32928. _super.call(this, component, child, auxInstruction);
  32929. }
  32930. return RedirectInstruction;
  32931. })(ResolvedInstruction);
  32932. exports.RedirectInstruction = RedirectInstruction;
  32933. /**
  32934. * A `ComponentInstruction` represents the route state for a single component. An `Instruction` is
  32935. * composed of a tree of these `ComponentInstruction`s.
  32936. *
  32937. * `ComponentInstructions` is a public API. Instances of `ComponentInstruction` are passed
  32938. * to route lifecycle hooks, like {@link CanActivate}.
  32939. *
  32940. * `ComponentInstruction`s are [https://en.wikipedia.org/wiki/Hash_consing](hash consed). You should
  32941. * never construct one yourself with "new." Instead, rely on {@link Router/RouteRecognizer} to
  32942. * construct `ComponentInstruction`s.
  32943. *
  32944. * You should not modify this object. It should be treated as immutable.
  32945. */
  32946. var ComponentInstruction = (function () {
  32947. function ComponentInstruction(urlPath, urlParams, data, componentType, terminal, specificity, params) {
  32948. if (params === void 0) { params = null; }
  32949. this.urlPath = urlPath;
  32950. this.urlParams = urlParams;
  32951. this.componentType = componentType;
  32952. this.terminal = terminal;
  32953. this.specificity = specificity;
  32954. this.params = params;
  32955. this.reuse = false;
  32956. this.routeData = lang_1.isPresent(data) ? data : exports.BLANK_ROUTE_DATA;
  32957. }
  32958. return ComponentInstruction;
  32959. })();
  32960. exports.ComponentInstruction = ComponentInstruction;
  32961. /***/ },
  32962. /* 230 */
  32963. /***/ function(module, exports, __webpack_require__) {
  32964. var lang_1 = __webpack_require__(5);
  32965. var exceptions_1 = __webpack_require__(14);
  32966. var collection_1 = __webpack_require__(12);
  32967. var url_parser_1 = __webpack_require__(231);
  32968. var TouchMap = (function () {
  32969. function TouchMap(map) {
  32970. var _this = this;
  32971. this.map = {};
  32972. this.keys = {};
  32973. if (lang_1.isPresent(map)) {
  32974. collection_1.StringMapWrapper.forEach(map, function (value, key) {
  32975. _this.map[key] = lang_1.isPresent(value) ? value.toString() : null;
  32976. _this.keys[key] = true;
  32977. });
  32978. }
  32979. }
  32980. TouchMap.prototype.get = function (key) {
  32981. collection_1.StringMapWrapper.delete(this.keys, key);
  32982. return this.map[key];
  32983. };
  32984. TouchMap.prototype.getUnused = function () {
  32985. var _this = this;
  32986. var unused = {};
  32987. var keys = collection_1.StringMapWrapper.keys(this.keys);
  32988. keys.forEach(function (key) { return unused[key] = collection_1.StringMapWrapper.get(_this.map, key); });
  32989. return unused;
  32990. };
  32991. return TouchMap;
  32992. })();
  32993. function normalizeString(obj) {
  32994. if (lang_1.isBlank(obj)) {
  32995. return null;
  32996. }
  32997. else {
  32998. return obj.toString();
  32999. }
  33000. }
  33001. var ContinuationSegment = (function () {
  33002. function ContinuationSegment() {
  33003. this.name = '';
  33004. }
  33005. ContinuationSegment.prototype.generate = function (params) { return ''; };
  33006. ContinuationSegment.prototype.match = function (path) { return true; };
  33007. return ContinuationSegment;
  33008. })();
  33009. var StaticSegment = (function () {
  33010. function StaticSegment(path) {
  33011. this.path = path;
  33012. this.name = '';
  33013. }
  33014. StaticSegment.prototype.match = function (path) { return path == this.path; };
  33015. StaticSegment.prototype.generate = function (params) { return this.path; };
  33016. return StaticSegment;
  33017. })();
  33018. var DynamicSegment = (function () {
  33019. function DynamicSegment(name) {
  33020. this.name = name;
  33021. }
  33022. DynamicSegment.prototype.match = function (path) { return path.length > 0; };
  33023. DynamicSegment.prototype.generate = function (params) {
  33024. if (!collection_1.StringMapWrapper.contains(params.map, this.name)) {
  33025. throw new exceptions_1.BaseException("Route generator for '" + this.name + "' was not included in parameters passed.");
  33026. }
  33027. return normalizeString(params.get(this.name));
  33028. };
  33029. return DynamicSegment;
  33030. })();
  33031. var StarSegment = (function () {
  33032. function StarSegment(name) {
  33033. this.name = name;
  33034. }
  33035. StarSegment.prototype.match = function (path) { return true; };
  33036. StarSegment.prototype.generate = function (params) { return normalizeString(params.get(this.name)); };
  33037. return StarSegment;
  33038. })();
  33039. var paramMatcher = /^:([^\/]+)$/g;
  33040. var wildcardMatcher = /^\*([^\/]+)$/g;
  33041. function parsePathString(route) {
  33042. // normalize route as not starting with a "/". Recognition will
  33043. // also normalize.
  33044. if (route.startsWith("/")) {
  33045. route = route.substring(1);
  33046. }
  33047. var segments = splitBySlash(route);
  33048. var results = [];
  33049. var specificity = 0;
  33050. // The "specificity" of a path is used to determine which route is used when multiple routes match
  33051. // a URL.
  33052. // Static segments (like "/foo") are the most specific, followed by dynamic segments (like
  33053. // "/:id"). Star segments
  33054. // add no specificity. Segments at the start of the path are more specific than proceeding ones.
  33055. // The code below uses place values to combine the different types of segments into a single
  33056. // integer that we can
  33057. // sort later. Each static segment is worth hundreds of points of specificity (10000, 9900, ...,
  33058. // 200), and each
  33059. // dynamic segment is worth single points of specificity (100, 99, ... 2).
  33060. if (segments.length > 98) {
  33061. throw new exceptions_1.BaseException("'" + route + "' has more than the maximum supported number of segments.");
  33062. }
  33063. var limit = segments.length - 1;
  33064. for (var i = 0; i <= limit; i++) {
  33065. var segment = segments[i], match;
  33066. if (lang_1.isPresent(match = lang_1.RegExpWrapper.firstMatch(paramMatcher, segment))) {
  33067. results.push(new DynamicSegment(match[1]));
  33068. specificity += (100 - i);
  33069. }
  33070. else if (lang_1.isPresent(match = lang_1.RegExpWrapper.firstMatch(wildcardMatcher, segment))) {
  33071. results.push(new StarSegment(match[1]));
  33072. }
  33073. else if (segment == '...') {
  33074. if (i < limit) {
  33075. throw new exceptions_1.BaseException("Unexpected \"...\" before the end of the path for \"" + route + "\".");
  33076. }
  33077. results.push(new ContinuationSegment());
  33078. }
  33079. else {
  33080. results.push(new StaticSegment(segment));
  33081. specificity += 100 * (100 - i);
  33082. }
  33083. }
  33084. var result = collection_1.StringMapWrapper.create();
  33085. collection_1.StringMapWrapper.set(result, 'segments', results);
  33086. collection_1.StringMapWrapper.set(result, 'specificity', specificity);
  33087. return result;
  33088. }
  33089. // this function is used to determine whether a route config path like `/foo/:id` collides with
  33090. // `/foo/:name`
  33091. function pathDslHash(segments) {
  33092. return segments.map(function (segment) {
  33093. if (segment instanceof StarSegment) {
  33094. return '*';
  33095. }
  33096. else if (segment instanceof ContinuationSegment) {
  33097. return '...';
  33098. }
  33099. else if (segment instanceof DynamicSegment) {
  33100. return ':';
  33101. }
  33102. else if (segment instanceof StaticSegment) {
  33103. return segment.path;
  33104. }
  33105. })
  33106. .join('/');
  33107. }
  33108. function splitBySlash(url) {
  33109. return url.split('/');
  33110. }
  33111. var RESERVED_CHARS = lang_1.RegExpWrapper.create('//|\\(|\\)|;|\\?|=');
  33112. function assertPath(path) {
  33113. if (lang_1.StringWrapper.contains(path, '#')) {
  33114. throw new exceptions_1.BaseException("Path \"" + path + "\" should not include \"#\". Use \"HashLocationStrategy\" instead.");
  33115. }
  33116. var illegalCharacter = lang_1.RegExpWrapper.firstMatch(RESERVED_CHARS, path);
  33117. if (lang_1.isPresent(illegalCharacter)) {
  33118. throw new exceptions_1.BaseException("Path \"" + path + "\" contains \"" + illegalCharacter[0] + "\" which is not allowed in a route config.");
  33119. }
  33120. }
  33121. /**
  33122. * Parses a URL string using a given matcher DSL, and generates URLs from param maps
  33123. */
  33124. var PathRecognizer = (function () {
  33125. function PathRecognizer(path) {
  33126. this.path = path;
  33127. this.terminal = true;
  33128. assertPath(path);
  33129. var parsed = parsePathString(path);
  33130. this._segments = parsed['segments'];
  33131. this.specificity = parsed['specificity'];
  33132. this.hash = pathDslHash(this._segments);
  33133. var lastSegment = this._segments[this._segments.length - 1];
  33134. this.terminal = !(lastSegment instanceof ContinuationSegment);
  33135. }
  33136. PathRecognizer.prototype.recognize = function (beginningSegment) {
  33137. var nextSegment = beginningSegment;
  33138. var currentSegment;
  33139. var positionalParams = {};
  33140. var captured = [];
  33141. for (var i = 0; i < this._segments.length; i += 1) {
  33142. var segment = this._segments[i];
  33143. currentSegment = nextSegment;
  33144. if (segment instanceof ContinuationSegment) {
  33145. break;
  33146. }
  33147. if (lang_1.isPresent(currentSegment)) {
  33148. captured.push(currentSegment.path);
  33149. // the star segment consumes all of the remaining URL, including matrix params
  33150. if (segment instanceof StarSegment) {
  33151. positionalParams[segment.name] = currentSegment.toString();
  33152. nextSegment = null;
  33153. break;
  33154. }
  33155. if (segment instanceof DynamicSegment) {
  33156. positionalParams[segment.name] = currentSegment.path;
  33157. }
  33158. else if (!segment.match(currentSegment.path)) {
  33159. return null;
  33160. }
  33161. nextSegment = currentSegment.child;
  33162. }
  33163. else if (!segment.match('')) {
  33164. return null;
  33165. }
  33166. }
  33167. if (this.terminal && lang_1.isPresent(nextSegment)) {
  33168. return null;
  33169. }
  33170. var urlPath = captured.join('/');
  33171. var auxiliary;
  33172. var urlParams;
  33173. var allParams;
  33174. if (lang_1.isPresent(currentSegment)) {
  33175. // If this is the root component, read query params. Otherwise, read matrix params.
  33176. var paramsSegment = beginningSegment instanceof url_parser_1.RootUrl ? beginningSegment : currentSegment;
  33177. allParams = lang_1.isPresent(paramsSegment.params) ?
  33178. collection_1.StringMapWrapper.merge(paramsSegment.params, positionalParams) :
  33179. positionalParams;
  33180. urlParams = url_parser_1.serializeParams(paramsSegment.params);
  33181. auxiliary = currentSegment.auxiliary;
  33182. }
  33183. else {
  33184. allParams = positionalParams;
  33185. auxiliary = [];
  33186. urlParams = [];
  33187. }
  33188. return { urlPath: urlPath, urlParams: urlParams, allParams: allParams, auxiliary: auxiliary, nextSegment: nextSegment };
  33189. };
  33190. PathRecognizer.prototype.generate = function (params) {
  33191. var paramTokens = new TouchMap(params);
  33192. var path = [];
  33193. for (var i = 0; i < this._segments.length; i++) {
  33194. var segment = this._segments[i];
  33195. if (!(segment instanceof ContinuationSegment)) {
  33196. path.push(segment.generate(paramTokens));
  33197. }
  33198. }
  33199. var urlPath = path.join('/');
  33200. var nonPositionalParams = paramTokens.getUnused();
  33201. var urlParams = url_parser_1.serializeParams(nonPositionalParams);
  33202. return { urlPath: urlPath, urlParams: urlParams };
  33203. };
  33204. return PathRecognizer;
  33205. })();
  33206. exports.PathRecognizer = PathRecognizer;
  33207. /***/ },
  33208. /* 231 */
  33209. /***/ function(module, exports, __webpack_require__) {
  33210. var __extends = (this && this.__extends) || function (d, b) {
  33211. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  33212. function __() { this.constructor = d; }
  33213. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  33214. };
  33215. var collection_1 = __webpack_require__(12);
  33216. var lang_1 = __webpack_require__(5);
  33217. var exceptions_1 = __webpack_require__(14);
  33218. /**
  33219. * This class represents a parsed URL
  33220. */
  33221. var Url = (function () {
  33222. function Url(path, child, auxiliary, params) {
  33223. if (child === void 0) { child = null; }
  33224. if (auxiliary === void 0) { auxiliary = lang_1.CONST_EXPR([]); }
  33225. if (params === void 0) { params = null; }
  33226. this.path = path;
  33227. this.child = child;
  33228. this.auxiliary = auxiliary;
  33229. this.params = params;
  33230. }
  33231. Url.prototype.toString = function () {
  33232. return this.path + this._matrixParamsToString() + this._auxToString() + this._childString();
  33233. };
  33234. Url.prototype.segmentToString = function () { return this.path + this._matrixParamsToString(); };
  33235. /** @internal */
  33236. Url.prototype._auxToString = function () {
  33237. return this.auxiliary.length > 0 ?
  33238. ('(' + this.auxiliary.map(function (sibling) { return sibling.toString(); }).join('//') + ')') :
  33239. '';
  33240. };
  33241. Url.prototype._matrixParamsToString = function () {
  33242. if (lang_1.isBlank(this.params)) {
  33243. return '';
  33244. }
  33245. return ';' + serializeParams(this.params).join(';');
  33246. };
  33247. /** @internal */
  33248. Url.prototype._childString = function () { return lang_1.isPresent(this.child) ? ('/' + this.child.toString()) : ''; };
  33249. return Url;
  33250. })();
  33251. exports.Url = Url;
  33252. var RootUrl = (function (_super) {
  33253. __extends(RootUrl, _super);
  33254. function RootUrl(path, child, auxiliary, params) {
  33255. if (child === void 0) { child = null; }
  33256. if (auxiliary === void 0) { auxiliary = lang_1.CONST_EXPR([]); }
  33257. if (params === void 0) { params = null; }
  33258. _super.call(this, path, child, auxiliary, params);
  33259. }
  33260. RootUrl.prototype.toString = function () {
  33261. return this.path + this._auxToString() + this._childString() + this._queryParamsToString();
  33262. };
  33263. RootUrl.prototype.segmentToString = function () { return this.path + this._queryParamsToString(); };
  33264. RootUrl.prototype._queryParamsToString = function () {
  33265. if (lang_1.isBlank(this.params)) {
  33266. return '';
  33267. }
  33268. return '?' + serializeParams(this.params).join('&');
  33269. };
  33270. return RootUrl;
  33271. })(Url);
  33272. exports.RootUrl = RootUrl;
  33273. function pathSegmentsToUrl(pathSegments) {
  33274. var url = new Url(pathSegments[pathSegments.length - 1]);
  33275. for (var i = pathSegments.length - 2; i >= 0; i -= 1) {
  33276. url = new Url(pathSegments[i], url);
  33277. }
  33278. return url;
  33279. }
  33280. exports.pathSegmentsToUrl = pathSegmentsToUrl;
  33281. var SEGMENT_RE = lang_1.RegExpWrapper.create('^[^\\/\\(\\)\\?;=&#]+');
  33282. function matchUrlSegment(str) {
  33283. var match = lang_1.RegExpWrapper.firstMatch(SEGMENT_RE, str);
  33284. return lang_1.isPresent(match) ? match[0] : '';
  33285. }
  33286. var UrlParser = (function () {
  33287. function UrlParser() {
  33288. }
  33289. UrlParser.prototype.peekStartsWith = function (str) { return this._remaining.startsWith(str); };
  33290. UrlParser.prototype.capture = function (str) {
  33291. if (!this._remaining.startsWith(str)) {
  33292. throw new exceptions_1.BaseException("Expected \"" + str + "\".");
  33293. }
  33294. this._remaining = this._remaining.substring(str.length);
  33295. };
  33296. UrlParser.prototype.parse = function (url) {
  33297. this._remaining = url;
  33298. if (url == '' || url == '/') {
  33299. return new Url('');
  33300. }
  33301. return this.parseRoot();
  33302. };
  33303. // segment + (aux segments) + (query params)
  33304. UrlParser.prototype.parseRoot = function () {
  33305. if (this.peekStartsWith('/')) {
  33306. this.capture('/');
  33307. }
  33308. var path = matchUrlSegment(this._remaining);
  33309. this.capture(path);
  33310. var aux = [];
  33311. if (this.peekStartsWith('(')) {
  33312. aux = this.parseAuxiliaryRoutes();
  33313. }
  33314. if (this.peekStartsWith(';')) {
  33315. // TODO: should these params just be dropped?
  33316. this.parseMatrixParams();
  33317. }
  33318. var child = null;
  33319. if (this.peekStartsWith('/') && !this.peekStartsWith('//')) {
  33320. this.capture('/');
  33321. child = this.parseSegment();
  33322. }
  33323. var queryParams = null;
  33324. if (this.peekStartsWith('?')) {
  33325. queryParams = this.parseQueryParams();
  33326. }
  33327. return new RootUrl(path, child, aux, queryParams);
  33328. };
  33329. // segment + (matrix params) + (aux segments)
  33330. UrlParser.prototype.parseSegment = function () {
  33331. if (this._remaining.length == 0) {
  33332. return null;
  33333. }
  33334. if (this.peekStartsWith('/')) {
  33335. this.capture('/');
  33336. }
  33337. var path = matchUrlSegment(this._remaining);
  33338. this.capture(path);
  33339. var matrixParams = null;
  33340. if (this.peekStartsWith(';')) {
  33341. matrixParams = this.parseMatrixParams();
  33342. }
  33343. var aux = [];
  33344. if (this.peekStartsWith('(')) {
  33345. aux = this.parseAuxiliaryRoutes();
  33346. }
  33347. var child = null;
  33348. if (this.peekStartsWith('/') && !this.peekStartsWith('//')) {
  33349. this.capture('/');
  33350. child = this.parseSegment();
  33351. }
  33352. return new Url(path, child, aux, matrixParams);
  33353. };
  33354. UrlParser.prototype.parseQueryParams = function () {
  33355. var params = {};
  33356. this.capture('?');
  33357. this.parseParam(params);
  33358. while (this._remaining.length > 0 && this.peekStartsWith('&')) {
  33359. this.capture('&');
  33360. this.parseParam(params);
  33361. }
  33362. return params;
  33363. };
  33364. UrlParser.prototype.parseMatrixParams = function () {
  33365. var params = {};
  33366. while (this._remaining.length > 0 && this.peekStartsWith(';')) {
  33367. this.capture(';');
  33368. this.parseParam(params);
  33369. }
  33370. return params;
  33371. };
  33372. UrlParser.prototype.parseParam = function (params) {
  33373. var key = matchUrlSegment(this._remaining);
  33374. if (lang_1.isBlank(key)) {
  33375. return;
  33376. }
  33377. this.capture(key);
  33378. var value = true;
  33379. if (this.peekStartsWith('=')) {
  33380. this.capture('=');
  33381. var valueMatch = matchUrlSegment(this._remaining);
  33382. if (lang_1.isPresent(valueMatch)) {
  33383. value = valueMatch;
  33384. this.capture(value);
  33385. }
  33386. }
  33387. params[key] = value;
  33388. };
  33389. UrlParser.prototype.parseAuxiliaryRoutes = function () {
  33390. var routes = [];
  33391. this.capture('(');
  33392. while (!this.peekStartsWith(')') && this._remaining.length > 0) {
  33393. routes.push(this.parseSegment());
  33394. if (this.peekStartsWith('//')) {
  33395. this.capture('//');
  33396. }
  33397. }
  33398. this.capture(')');
  33399. return routes;
  33400. };
  33401. return UrlParser;
  33402. })();
  33403. exports.UrlParser = UrlParser;
  33404. exports.parser = new UrlParser();
  33405. function serializeParams(paramMap) {
  33406. var params = [];
  33407. if (lang_1.isPresent(paramMap)) {
  33408. collection_1.StringMapWrapper.forEach(paramMap, function (value, key) {
  33409. if (value == true) {
  33410. params.push(key);
  33411. }
  33412. else {
  33413. params.push(key + '=' + value);
  33414. }
  33415. });
  33416. }
  33417. return params;
  33418. }
  33419. exports.serializeParams = serializeParams;
  33420. /***/ },
  33421. /* 232 */
  33422. /***/ function(module, exports, __webpack_require__) {
  33423. var lang_1 = __webpack_require__(5);
  33424. var exceptions_1 = __webpack_require__(14);
  33425. var collection_1 = __webpack_require__(12);
  33426. var async_1 = __webpack_require__(60);
  33427. var route_recognizer_1 = __webpack_require__(228);
  33428. var route_config_impl_1 = __webpack_require__(227);
  33429. var async_route_handler_1 = __webpack_require__(233);
  33430. var sync_route_handler_1 = __webpack_require__(234);
  33431. /**
  33432. * `ComponentRecognizer` is responsible for recognizing routes for a single component.
  33433. * It is consumed by `RouteRegistry`, which knows how to recognize an entire hierarchy of
  33434. * components.
  33435. */
  33436. var ComponentRecognizer = (function () {
  33437. function ComponentRecognizer() {
  33438. this.names = new collection_1.Map();
  33439. // map from name to recognizer
  33440. this.auxNames = new collection_1.Map();
  33441. // map from starting path to recognizer
  33442. this.auxRoutes = new collection_1.Map();
  33443. // TODO: optimize this into a trie
  33444. this.matchers = [];
  33445. this.defaultRoute = null;
  33446. }
  33447. /**
  33448. * returns whether or not the config is terminal
  33449. */
  33450. ComponentRecognizer.prototype.config = function (config) {
  33451. var handler;
  33452. if (lang_1.isPresent(config.name) && config.name[0].toUpperCase() != config.name[0]) {
  33453. var suggestedName = config.name[0].toUpperCase() + config.name.substring(1);
  33454. throw new exceptions_1.BaseException("Route \"" + config.path + "\" with name \"" + config.name + "\" does not begin with an uppercase letter. Route names should be CamelCase like \"" + suggestedName + "\".");
  33455. }
  33456. if (config instanceof route_config_impl_1.AuxRoute) {
  33457. handler = new sync_route_handler_1.SyncRouteHandler(config.component, config.data);
  33458. var path = config.path.startsWith('/') ? config.path.substring(1) : config.path;
  33459. var recognizer = new route_recognizer_1.RouteRecognizer(config.path, handler);
  33460. this.auxRoutes.set(path, recognizer);
  33461. if (lang_1.isPresent(config.name)) {
  33462. this.auxNames.set(config.name, recognizer);
  33463. }
  33464. return recognizer.terminal;
  33465. }
  33466. var useAsDefault = false;
  33467. if (config instanceof route_config_impl_1.Redirect) {
  33468. var redirector = new route_recognizer_1.RedirectRecognizer(config.path, config.redirectTo);
  33469. this._assertNoHashCollision(redirector.hash, config.path);
  33470. this.matchers.push(redirector);
  33471. return true;
  33472. }
  33473. if (config instanceof route_config_impl_1.Route) {
  33474. handler = new sync_route_handler_1.SyncRouteHandler(config.component, config.data);
  33475. useAsDefault = lang_1.isPresent(config.useAsDefault) && config.useAsDefault;
  33476. }
  33477. else if (config instanceof route_config_impl_1.AsyncRoute) {
  33478. handler = new async_route_handler_1.AsyncRouteHandler(config.loader, config.data);
  33479. useAsDefault = lang_1.isPresent(config.useAsDefault) && config.useAsDefault;
  33480. }
  33481. var recognizer = new route_recognizer_1.RouteRecognizer(config.path, handler);
  33482. this._assertNoHashCollision(recognizer.hash, config.path);
  33483. if (useAsDefault) {
  33484. if (lang_1.isPresent(this.defaultRoute)) {
  33485. throw new exceptions_1.BaseException("Only one route can be default");
  33486. }
  33487. this.defaultRoute = recognizer;
  33488. }
  33489. this.matchers.push(recognizer);
  33490. if (lang_1.isPresent(config.name)) {
  33491. this.names.set(config.name, recognizer);
  33492. }
  33493. return recognizer.terminal;
  33494. };
  33495. ComponentRecognizer.prototype._assertNoHashCollision = function (hash, path) {
  33496. this.matchers.forEach(function (matcher) {
  33497. if (hash == matcher.hash) {
  33498. throw new exceptions_1.BaseException("Configuration '" + path + "' conflicts with existing route '" + matcher.path + "'");
  33499. }
  33500. });
  33501. };
  33502. /**
  33503. * Given a URL, returns a list of `RouteMatch`es, which are partial recognitions for some route.
  33504. */
  33505. ComponentRecognizer.prototype.recognize = function (urlParse) {
  33506. var solutions = [];
  33507. this.matchers.forEach(function (routeRecognizer) {
  33508. var pathMatch = routeRecognizer.recognize(urlParse);
  33509. if (lang_1.isPresent(pathMatch)) {
  33510. solutions.push(pathMatch);
  33511. }
  33512. });
  33513. return solutions;
  33514. };
  33515. ComponentRecognizer.prototype.recognizeAuxiliary = function (urlParse) {
  33516. var routeRecognizer = this.auxRoutes.get(urlParse.path);
  33517. if (lang_1.isPresent(routeRecognizer)) {
  33518. return [routeRecognizer.recognize(urlParse)];
  33519. }
  33520. return [async_1.PromiseWrapper.resolve(null)];
  33521. };
  33522. ComponentRecognizer.prototype.hasRoute = function (name) { return this.names.has(name); };
  33523. ComponentRecognizer.prototype.componentLoaded = function (name) {
  33524. return this.hasRoute(name) && lang_1.isPresent(this.names.get(name).handler.componentType);
  33525. };
  33526. ComponentRecognizer.prototype.loadComponent = function (name) {
  33527. return this.names.get(name).handler.resolveComponentType();
  33528. };
  33529. ComponentRecognizer.prototype.generate = function (name, params) {
  33530. var pathRecognizer = this.names.get(name);
  33531. if (lang_1.isBlank(pathRecognizer)) {
  33532. return null;
  33533. }
  33534. return pathRecognizer.generate(params);
  33535. };
  33536. ComponentRecognizer.prototype.generateAuxiliary = function (name, params) {
  33537. var pathRecognizer = this.auxNames.get(name);
  33538. if (lang_1.isBlank(pathRecognizer)) {
  33539. return null;
  33540. }
  33541. return pathRecognizer.generate(params);
  33542. };
  33543. return ComponentRecognizer;
  33544. })();
  33545. exports.ComponentRecognizer = ComponentRecognizer;
  33546. /***/ },
  33547. /* 233 */
  33548. /***/ function(module, exports, __webpack_require__) {
  33549. var lang_1 = __webpack_require__(5);
  33550. var instruction_1 = __webpack_require__(229);
  33551. var AsyncRouteHandler = (function () {
  33552. function AsyncRouteHandler(_loader, data) {
  33553. if (data === void 0) { data = null; }
  33554. this._loader = _loader;
  33555. /** @internal */
  33556. this._resolvedComponent = null;
  33557. this.data = lang_1.isPresent(data) ? new instruction_1.RouteData(data) : instruction_1.BLANK_ROUTE_DATA;
  33558. }
  33559. AsyncRouteHandler.prototype.resolveComponentType = function () {
  33560. var _this = this;
  33561. if (lang_1.isPresent(this._resolvedComponent)) {
  33562. return this._resolvedComponent;
  33563. }
  33564. return this._resolvedComponent = this._loader().then(function (componentType) {
  33565. _this.componentType = componentType;
  33566. return componentType;
  33567. });
  33568. };
  33569. return AsyncRouteHandler;
  33570. })();
  33571. exports.AsyncRouteHandler = AsyncRouteHandler;
  33572. /***/ },
  33573. /* 234 */
  33574. /***/ function(module, exports, __webpack_require__) {
  33575. var async_1 = __webpack_require__(60);
  33576. var lang_1 = __webpack_require__(5);
  33577. var instruction_1 = __webpack_require__(229);
  33578. var SyncRouteHandler = (function () {
  33579. function SyncRouteHandler(componentType, data) {
  33580. this.componentType = componentType;
  33581. /** @internal */
  33582. this._resolvedComponent = null;
  33583. this._resolvedComponent = async_1.PromiseWrapper.resolve(componentType);
  33584. this.data = lang_1.isPresent(data) ? new instruction_1.RouteData(data) : instruction_1.BLANK_ROUTE_DATA;
  33585. }
  33586. SyncRouteHandler.prototype.resolveComponentType = function () { return this._resolvedComponent; };
  33587. return SyncRouteHandler;
  33588. })();
  33589. exports.SyncRouteHandler = SyncRouteHandler;
  33590. /***/ },
  33591. /* 235 */
  33592. /***/ function(module, exports, __webpack_require__) {
  33593. var route_config_decorator_1 = __webpack_require__(236);
  33594. var lang_1 = __webpack_require__(5);
  33595. var exceptions_1 = __webpack_require__(14);
  33596. /**
  33597. * Given a JS Object that represents a route config, returns a corresponding Route, AsyncRoute,
  33598. * AuxRoute or Redirect object.
  33599. *
  33600. * Also wraps an AsyncRoute's loader function to add the loaded component's route config to the
  33601. * `RouteRegistry`.
  33602. */
  33603. function normalizeRouteConfig(config, registry) {
  33604. if (config instanceof route_config_decorator_1.AsyncRoute) {
  33605. var wrappedLoader = wrapLoaderToReconfigureRegistry(config.loader, registry);
  33606. return new route_config_decorator_1.AsyncRoute({
  33607. path: config.path,
  33608. loader: wrappedLoader,
  33609. name: config.name,
  33610. data: config.data,
  33611. useAsDefault: config.useAsDefault
  33612. });
  33613. }
  33614. if (config instanceof route_config_decorator_1.Route || config instanceof route_config_decorator_1.Redirect || config instanceof route_config_decorator_1.AuxRoute) {
  33615. return config;
  33616. }
  33617. if ((+!!config.component) + (+!!config.redirectTo) + (+!!config.loader) != 1) {
  33618. throw new exceptions_1.BaseException("Route config should contain exactly one \"component\", \"loader\", or \"redirectTo\" property.");
  33619. }
  33620. if (config.as && config.name) {
  33621. throw new exceptions_1.BaseException("Route config should contain exactly one \"as\" or \"name\" property.");
  33622. }
  33623. if (config.as) {
  33624. config.name = config.as;
  33625. }
  33626. if (config.loader) {
  33627. var wrappedLoader = wrapLoaderToReconfigureRegistry(config.loader, registry);
  33628. return new route_config_decorator_1.AsyncRoute({
  33629. path: config.path,
  33630. loader: wrappedLoader,
  33631. name: config.name,
  33632. useAsDefault: config.useAsDefault
  33633. });
  33634. }
  33635. if (config.aux) {
  33636. return new route_config_decorator_1.AuxRoute({ path: config.aux, component: config.component, name: config.name });
  33637. }
  33638. if (config.component) {
  33639. if (typeof config.component == 'object') {
  33640. var componentDefinitionObject = config.component;
  33641. if (componentDefinitionObject.type == 'constructor') {
  33642. return new route_config_decorator_1.Route({
  33643. path: config.path,
  33644. component: componentDefinitionObject.constructor,
  33645. name: config.name,
  33646. data: config.data,
  33647. useAsDefault: config.useAsDefault
  33648. });
  33649. }
  33650. else if (componentDefinitionObject.type == 'loader') {
  33651. return new route_config_decorator_1.AsyncRoute({
  33652. path: config.path,
  33653. loader: componentDefinitionObject.loader,
  33654. name: config.name,
  33655. useAsDefault: config.useAsDefault
  33656. });
  33657. }
  33658. else {
  33659. throw new exceptions_1.BaseException("Invalid component type \"" + componentDefinitionObject.type + "\". Valid types are \"constructor\" and \"loader\".");
  33660. }
  33661. }
  33662. return new route_config_decorator_1.Route(config);
  33663. }
  33664. if (config.redirectTo) {
  33665. return new route_config_decorator_1.Redirect({ path: config.path, redirectTo: config.redirectTo });
  33666. }
  33667. return config;
  33668. }
  33669. exports.normalizeRouteConfig = normalizeRouteConfig;
  33670. function wrapLoaderToReconfigureRegistry(loader, registry) {
  33671. return function () {
  33672. return loader().then(function (componentType) {
  33673. registry.configFromComponent(componentType);
  33674. return componentType;
  33675. });
  33676. };
  33677. }
  33678. function assertComponentExists(component, path) {
  33679. if (!lang_1.isType(component)) {
  33680. throw new exceptions_1.BaseException("Component for route \"" + path + "\" is not defined, or is not a class.");
  33681. }
  33682. }
  33683. exports.assertComponentExists = assertComponentExists;
  33684. /***/ },
  33685. /* 236 */
  33686. /***/ function(module, exports, __webpack_require__) {
  33687. var route_config_impl_1 = __webpack_require__(227);
  33688. var decorators_1 = __webpack_require__(9);
  33689. var route_config_impl_2 = __webpack_require__(227);
  33690. exports.Route = route_config_impl_2.Route;
  33691. exports.Redirect = route_config_impl_2.Redirect;
  33692. exports.AuxRoute = route_config_impl_2.AuxRoute;
  33693. exports.AsyncRoute = route_config_impl_2.AsyncRoute;
  33694. // Copied from RouteConfig in route_config_impl.
  33695. /**
  33696. * The `RouteConfig` decorator defines routes for a given component.
  33697. *
  33698. * It takes an array of {@link RouteDefinition}s.
  33699. */
  33700. exports.RouteConfig = decorators_1.makeDecorator(route_config_impl_1.RouteConfig);
  33701. /***/ },
  33702. /* 237 */
  33703. /***/ function(module, exports, __webpack_require__) {
  33704. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  33705. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  33706. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  33707. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  33708. return c > 3 && r && Object.defineProperty(target, key, r), r;
  33709. };
  33710. var __metadata = (this && this.__metadata) || function (k, v) {
  33711. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  33712. };
  33713. var location_strategy_1 = __webpack_require__(238);
  33714. var async_1 = __webpack_require__(60);
  33715. var core_1 = __webpack_require__(2);
  33716. /**
  33717. * `Location` is a service that applications can use to interact with a browser's URL.
  33718. * Depending on which {@link LocationStrategy} is used, `Location` will either persist
  33719. * to the URL's path or the URL's hash segment.
  33720. *
  33721. * Note: it's better to use {@link Router#navigate} service to trigger route changes. Use
  33722. * `Location` only if you need to interact with or create normalized URLs outside of
  33723. * routing.
  33724. *
  33725. * `Location` is responsible for normalizing the URL against the application's base href.
  33726. * A normalized URL is absolute from the URL host, includes the application's base href, and has no
  33727. * trailing slash:
  33728. * - `/my/app/user/123` is normalized
  33729. * - `my/app/user/123` **is not** normalized
  33730. * - `/my/app/user/123/` **is not** normalized
  33731. *
  33732. * ### Example
  33733. *
  33734. * ```
  33735. * import {Component} from 'angular2/core';
  33736. * import {
  33737. * ROUTER_DIRECTIVES,
  33738. * ROUTER_PROVIDERS,
  33739. * RouteConfig,
  33740. * Location
  33741. * } from 'angular2/router';
  33742. *
  33743. * @Component({directives: [ROUTER_DIRECTIVES]})
  33744. * @RouteConfig([
  33745. * {...},
  33746. * ])
  33747. * class AppCmp {
  33748. * constructor(location: Location) {
  33749. * location.go('/foo');
  33750. * }
  33751. * }
  33752. *
  33753. * bootstrap(AppCmp, [ROUTER_PROVIDERS]);
  33754. * ```
  33755. */
  33756. var Location = (function () {
  33757. function Location(platformStrategy) {
  33758. var _this = this;
  33759. this.platformStrategy = platformStrategy;
  33760. /** @internal */
  33761. this._subject = new async_1.EventEmitter();
  33762. var browserBaseHref = this.platformStrategy.getBaseHref();
  33763. this._baseHref = stripTrailingSlash(stripIndexHtml(browserBaseHref));
  33764. this.platformStrategy.onPopState(function (ev) {
  33765. async_1.ObservableWrapper.callEmit(_this._subject, { 'url': _this.path(), 'pop': true, 'type': ev.type });
  33766. });
  33767. }
  33768. /**
  33769. * Returns the normalized URL path.
  33770. */
  33771. Location.prototype.path = function () { return this.normalize(this.platformStrategy.path()); };
  33772. /**
  33773. * Given a string representing a URL, returns the normalized URL path without leading or
  33774. * trailing slashes
  33775. */
  33776. Location.prototype.normalize = function (url) {
  33777. return stripTrailingSlash(_stripBaseHref(this._baseHref, stripIndexHtml(url)));
  33778. };
  33779. /**
  33780. * Given a string representing a URL, returns the platform-specific external URL path.
  33781. * If the given URL doesn't begin with a leading slash (`'/'`), this method adds one
  33782. * before normalizing. This method will also add a hash if `HashLocationStrategy` is
  33783. * used, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use.
  33784. */
  33785. Location.prototype.prepareExternalUrl = function (url) {
  33786. if (url.length > 0 && !url.startsWith('/')) {
  33787. url = '/' + url;
  33788. }
  33789. return this.platformStrategy.prepareExternalUrl(url);
  33790. };
  33791. // TODO: rename this method to pushState
  33792. /**
  33793. * Changes the browsers URL to the normalized version of the given URL, and pushes a
  33794. * new item onto the platform's history.
  33795. */
  33796. Location.prototype.go = function (path, query) {
  33797. if (query === void 0) { query = ''; }
  33798. this.platformStrategy.pushState(null, '', path, query);
  33799. };
  33800. /**
  33801. * Changes the browsers URL to the normalized version of the given URL, and replaces
  33802. * the top item on the platform's history stack.
  33803. */
  33804. Location.prototype.replaceState = function (path, query) {
  33805. if (query === void 0) { query = ''; }
  33806. this.platformStrategy.replaceState(null, '', path, query);
  33807. };
  33808. /**
  33809. * Navigates forward in the platform's history.
  33810. */
  33811. Location.prototype.forward = function () { this.platformStrategy.forward(); };
  33812. /**
  33813. * Navigates back in the platform's history.
  33814. */
  33815. Location.prototype.back = function () { this.platformStrategy.back(); };
  33816. /**
  33817. * Subscribe to the platform's `popState` events.
  33818. */
  33819. Location.prototype.subscribe = function (onNext, onThrow, onReturn) {
  33820. if (onThrow === void 0) { onThrow = null; }
  33821. if (onReturn === void 0) { onReturn = null; }
  33822. return async_1.ObservableWrapper.subscribe(this._subject, onNext, onThrow, onReturn);
  33823. };
  33824. Location = __decorate([
  33825. core_1.Injectable(),
  33826. __metadata('design:paramtypes', [location_strategy_1.LocationStrategy])
  33827. ], Location);
  33828. return Location;
  33829. })();
  33830. exports.Location = Location;
  33831. function _stripBaseHref(baseHref, url) {
  33832. if (baseHref.length > 0 && url.startsWith(baseHref)) {
  33833. return url.substring(baseHref.length);
  33834. }
  33835. return url;
  33836. }
  33837. function stripIndexHtml(url) {
  33838. if (/\/index.html$/g.test(url)) {
  33839. // '/index.html'.length == 11
  33840. return url.substring(0, url.length - 11);
  33841. }
  33842. return url;
  33843. }
  33844. function stripTrailingSlash(url) {
  33845. if (/\/$/g.test(url)) {
  33846. url = url.substring(0, url.length - 1);
  33847. }
  33848. return url;
  33849. }
  33850. /***/ },
  33851. /* 238 */
  33852. /***/ function(module, exports, __webpack_require__) {
  33853. var lang_1 = __webpack_require__(5);
  33854. var core_1 = __webpack_require__(2);
  33855. /**
  33856. * `LocationStrategy` is responsible for representing and reading route state
  33857. * from the browser's URL. Angular provides two strategies:
  33858. * {@link HashLocationStrategy} (default) and {@link PathLocationStrategy}.
  33859. *
  33860. * This is used under the hood of the {@link Location} service.
  33861. *
  33862. * Applications should use the {@link Router} or {@link Location} services to
  33863. * interact with application route state.
  33864. *
  33865. * For instance, {@link HashLocationStrategy} produces URLs like
  33866. * `http://example.com#/foo`, and {@link PathLocationStrategy} produces
  33867. * `http://example.com/foo` as an equivalent URL.
  33868. *
  33869. * See these two classes for more.
  33870. */
  33871. var LocationStrategy = (function () {
  33872. function LocationStrategy() {
  33873. }
  33874. return LocationStrategy;
  33875. })();
  33876. exports.LocationStrategy = LocationStrategy;
  33877. /**
  33878. * The `APP_BASE_HREF` token represents the base href to be used with the
  33879. * {@link PathLocationStrategy}.
  33880. *
  33881. * If you're using {@link PathLocationStrategy}, you must provide a provider to a string
  33882. * representing the URL prefix that should be preserved when generating and recognizing
  33883. * URLs.
  33884. *
  33885. * ### Example
  33886. *
  33887. * ```
  33888. * import {Component} from 'angular2/core';
  33889. * import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from 'angular2/router';
  33890. *
  33891. * @Component({directives: [ROUTER_DIRECTIVES]})
  33892. * @RouteConfig([
  33893. * {...},
  33894. * ])
  33895. * class AppCmp {
  33896. * // ...
  33897. * }
  33898. *
  33899. * bootstrap(AppCmp, [
  33900. * ROUTER_PROVIDERS,
  33901. * PathLocationStrategy,
  33902. * provide(APP_BASE_HREF, {useValue: '/my/app'})
  33903. * ]);
  33904. * ```
  33905. */
  33906. exports.APP_BASE_HREF = lang_1.CONST_EXPR(new core_1.OpaqueToken('appBaseHref'));
  33907. function normalizeQueryParams(params) {
  33908. return (params.length > 0 && params.substring(0, 1) != '?') ? ('?' + params) : params;
  33909. }
  33910. exports.normalizeQueryParams = normalizeQueryParams;
  33911. function joinWithSlash(start, end) {
  33912. if (start.length == 0) {
  33913. return end;
  33914. }
  33915. if (end.length == 0) {
  33916. return start;
  33917. }
  33918. var slashes = 0;
  33919. if (start.endsWith('/')) {
  33920. slashes++;
  33921. }
  33922. if (end.startsWith('/')) {
  33923. slashes++;
  33924. }
  33925. if (slashes == 2) {
  33926. return start + end.substring(1);
  33927. }
  33928. if (slashes == 1) {
  33929. return start + end;
  33930. }
  33931. return start + '/' + end;
  33932. }
  33933. exports.joinWithSlash = joinWithSlash;
  33934. /***/ },
  33935. /* 239 */
  33936. /***/ function(module, exports, __webpack_require__) {
  33937. var lang_1 = __webpack_require__(5);
  33938. var lifecycle_annotations_impl_1 = __webpack_require__(240);
  33939. var reflection_1 = __webpack_require__(16);
  33940. function hasLifecycleHook(e, type) {
  33941. if (!(type instanceof lang_1.Type))
  33942. return false;
  33943. return e.name in type.prototype;
  33944. }
  33945. exports.hasLifecycleHook = hasLifecycleHook;
  33946. function getCanActivateHook(type) {
  33947. var annotations = reflection_1.reflector.annotations(type);
  33948. for (var i = 0; i < annotations.length; i += 1) {
  33949. var annotation = annotations[i];
  33950. if (annotation instanceof lifecycle_annotations_impl_1.CanActivate) {
  33951. return annotation.fn;
  33952. }
  33953. }
  33954. return null;
  33955. }
  33956. exports.getCanActivateHook = getCanActivateHook;
  33957. /***/ },
  33958. /* 240 */
  33959. /***/ function(module, exports, __webpack_require__) {
  33960. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  33961. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  33962. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  33963. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  33964. return c > 3 && r && Object.defineProperty(target, key, r), r;
  33965. };
  33966. var __metadata = (this && this.__metadata) || function (k, v) {
  33967. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  33968. };
  33969. var lang_1 = __webpack_require__(5);
  33970. var RouteLifecycleHook = (function () {
  33971. function RouteLifecycleHook(name) {
  33972. this.name = name;
  33973. }
  33974. RouteLifecycleHook = __decorate([
  33975. lang_1.CONST(),
  33976. __metadata('design:paramtypes', [String])
  33977. ], RouteLifecycleHook);
  33978. return RouteLifecycleHook;
  33979. })();
  33980. exports.RouteLifecycleHook = RouteLifecycleHook;
  33981. var CanActivate = (function () {
  33982. function CanActivate(fn) {
  33983. this.fn = fn;
  33984. }
  33985. CanActivate = __decorate([
  33986. lang_1.CONST(),
  33987. __metadata('design:paramtypes', [Function])
  33988. ], CanActivate);
  33989. return CanActivate;
  33990. })();
  33991. exports.CanActivate = CanActivate;
  33992. exports.routerCanReuse = lang_1.CONST_EXPR(new RouteLifecycleHook("routerCanReuse"));
  33993. exports.routerCanDeactivate = lang_1.CONST_EXPR(new RouteLifecycleHook("routerCanDeactivate"));
  33994. exports.routerOnActivate = lang_1.CONST_EXPR(new RouteLifecycleHook("routerOnActivate"));
  33995. exports.routerOnReuse = lang_1.CONST_EXPR(new RouteLifecycleHook("routerOnReuse"));
  33996. exports.routerOnDeactivate = lang_1.CONST_EXPR(new RouteLifecycleHook("routerOnDeactivate"));
  33997. /***/ },
  33998. /* 241 */
  33999. /***/ function(module, exports, __webpack_require__) {
  34000. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  34001. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34002. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34003. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  34004. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34005. };
  34006. var __metadata = (this && this.__metadata) || function (k, v) {
  34007. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  34008. };
  34009. var __param = (this && this.__param) || function (paramIndex, decorator) {
  34010. return function (target, key) { decorator(target, key, paramIndex); }
  34011. };
  34012. var async_1 = __webpack_require__(60);
  34013. var collection_1 = __webpack_require__(12);
  34014. var lang_1 = __webpack_require__(5);
  34015. var exceptions_1 = __webpack_require__(14);
  34016. var core_1 = __webpack_require__(2);
  34017. var routerMod = __webpack_require__(225);
  34018. var instruction_1 = __webpack_require__(229);
  34019. var hookMod = __webpack_require__(242);
  34020. var route_lifecycle_reflector_1 = __webpack_require__(239);
  34021. var _resolveToTrue = async_1.PromiseWrapper.resolve(true);
  34022. /**
  34023. * A router outlet is a placeholder that Angular dynamically fills based on the application's route.
  34024. *
  34025. * ## Use
  34026. *
  34027. * ```
  34028. * <router-outlet></router-outlet>
  34029. * ```
  34030. */
  34031. var RouterOutlet = (function () {
  34032. function RouterOutlet(_elementRef, _loader, _parentRouter, nameAttr) {
  34033. this._elementRef = _elementRef;
  34034. this._loader = _loader;
  34035. this._parentRouter = _parentRouter;
  34036. this.name = null;
  34037. this._componentRef = null;
  34038. this._currentInstruction = null;
  34039. if (lang_1.isPresent(nameAttr)) {
  34040. this.name = nameAttr;
  34041. this._parentRouter.registerAuxOutlet(this);
  34042. }
  34043. else {
  34044. this._parentRouter.registerPrimaryOutlet(this);
  34045. }
  34046. }
  34047. /**
  34048. * Called by the Router to instantiate a new component during the commit phase of a navigation.
  34049. * This method in turn is responsible for calling the `routerOnActivate` hook of its child.
  34050. */
  34051. RouterOutlet.prototype.activate = function (nextInstruction) {
  34052. var _this = this;
  34053. var previousInstruction = this._currentInstruction;
  34054. this._currentInstruction = nextInstruction;
  34055. var componentType = nextInstruction.componentType;
  34056. var childRouter = this._parentRouter.childRouter(componentType);
  34057. var providers = core_1.Injector.resolve([
  34058. core_1.provide(instruction_1.RouteData, { useValue: nextInstruction.routeData }),
  34059. core_1.provide(instruction_1.RouteParams, { useValue: new instruction_1.RouteParams(nextInstruction.params) }),
  34060. core_1.provide(routerMod.Router, { useValue: childRouter })
  34061. ]);
  34062. return this._loader.loadNextToLocation(componentType, this._elementRef, providers)
  34063. .then(function (componentRef) {
  34064. _this._componentRef = componentRef;
  34065. if (route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerOnActivate, componentType)) {
  34066. return _this._componentRef.instance
  34067. .routerOnActivate(nextInstruction, previousInstruction);
  34068. }
  34069. });
  34070. };
  34071. /**
  34072. * Called by the {@link Router} during the commit phase of a navigation when an outlet
  34073. * reuses a component between different routes.
  34074. * This method in turn is responsible for calling the `routerOnReuse` hook of its child.
  34075. */
  34076. RouterOutlet.prototype.reuse = function (nextInstruction) {
  34077. var previousInstruction = this._currentInstruction;
  34078. this._currentInstruction = nextInstruction;
  34079. if (lang_1.isBlank(this._componentRef)) {
  34080. throw new exceptions_1.BaseException("Cannot reuse an outlet that does not contain a component.");
  34081. }
  34082. return async_1.PromiseWrapper.resolve(route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerOnReuse, this._currentInstruction.componentType) ?
  34083. this._componentRef.instance
  34084. .routerOnReuse(nextInstruction, previousInstruction) :
  34085. true);
  34086. };
  34087. /**
  34088. * Called by the {@link Router} when an outlet disposes of a component's contents.
  34089. * This method in turn is responsible for calling the `routerOnDeactivate` hook of its child.
  34090. */
  34091. RouterOutlet.prototype.deactivate = function (nextInstruction) {
  34092. var _this = this;
  34093. var next = _resolveToTrue;
  34094. if (lang_1.isPresent(this._componentRef) && lang_1.isPresent(this._currentInstruction) &&
  34095. route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerOnDeactivate, this._currentInstruction.componentType)) {
  34096. next = async_1.PromiseWrapper.resolve(this._componentRef.instance
  34097. .routerOnDeactivate(nextInstruction, this._currentInstruction));
  34098. }
  34099. return next.then(function (_) {
  34100. if (lang_1.isPresent(_this._componentRef)) {
  34101. _this._componentRef.dispose();
  34102. _this._componentRef = null;
  34103. }
  34104. });
  34105. };
  34106. /**
  34107. * Called by the {@link Router} during recognition phase of a navigation.
  34108. *
  34109. * If this resolves to `false`, the given navigation is cancelled.
  34110. *
  34111. * This method delegates to the child component's `routerCanDeactivate` hook if it exists,
  34112. * and otherwise resolves to true.
  34113. */
  34114. RouterOutlet.prototype.routerCanDeactivate = function (nextInstruction) {
  34115. if (lang_1.isBlank(this._currentInstruction)) {
  34116. return _resolveToTrue;
  34117. }
  34118. if (route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerCanDeactivate, this._currentInstruction.componentType)) {
  34119. return async_1.PromiseWrapper.resolve(this._componentRef.instance
  34120. .routerCanDeactivate(nextInstruction, this._currentInstruction));
  34121. }
  34122. return _resolveToTrue;
  34123. };
  34124. /**
  34125. * Called by the {@link Router} during recognition phase of a navigation.
  34126. *
  34127. * If the new child component has a different Type than the existing child component,
  34128. * this will resolve to `false`. You can't reuse an old component when the new component
  34129. * is of a different Type.
  34130. *
  34131. * Otherwise, this method delegates to the child component's `routerCanReuse` hook if it exists,
  34132. * or resolves to true if the hook is not present.
  34133. */
  34134. RouterOutlet.prototype.routerCanReuse = function (nextInstruction) {
  34135. var result;
  34136. if (lang_1.isBlank(this._currentInstruction) ||
  34137. this._currentInstruction.componentType != nextInstruction.componentType) {
  34138. result = false;
  34139. }
  34140. else if (route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerCanReuse, this._currentInstruction.componentType)) {
  34141. result = this._componentRef.instance
  34142. .routerCanReuse(nextInstruction, this._currentInstruction);
  34143. }
  34144. else {
  34145. result = nextInstruction == this._currentInstruction ||
  34146. (lang_1.isPresent(nextInstruction.params) && lang_1.isPresent(this._currentInstruction.params) &&
  34147. collection_1.StringMapWrapper.equals(nextInstruction.params, this._currentInstruction.params));
  34148. }
  34149. return async_1.PromiseWrapper.resolve(result);
  34150. };
  34151. RouterOutlet = __decorate([
  34152. core_1.Directive({ selector: 'router-outlet' }),
  34153. __param(3, core_1.Attribute('name')),
  34154. __metadata('design:paramtypes', [core_1.ElementRef, core_1.DynamicComponentLoader, routerMod.Router, String])
  34155. ], RouterOutlet);
  34156. return RouterOutlet;
  34157. })();
  34158. exports.RouterOutlet = RouterOutlet;
  34159. /***/ },
  34160. /* 242 */
  34161. /***/ function(module, exports, __webpack_require__) {
  34162. /**
  34163. * This indirection is needed to free up Component, etc symbols in the public API
  34164. * to be used by the decorator versions of these annotations.
  34165. */
  34166. var decorators_1 = __webpack_require__(9);
  34167. var lifecycle_annotations_impl_1 = __webpack_require__(240);
  34168. var lifecycle_annotations_impl_2 = __webpack_require__(240);
  34169. exports.routerCanReuse = lifecycle_annotations_impl_2.routerCanReuse;
  34170. exports.routerCanDeactivate = lifecycle_annotations_impl_2.routerCanDeactivate;
  34171. exports.routerOnActivate = lifecycle_annotations_impl_2.routerOnActivate;
  34172. exports.routerOnReuse = lifecycle_annotations_impl_2.routerOnReuse;
  34173. exports.routerOnDeactivate = lifecycle_annotations_impl_2.routerOnDeactivate;
  34174. /**
  34175. * Defines route lifecycle hook `CanActivate`, which is called by the router to determine
  34176. * if a component can be instantiated as part of a navigation.
  34177. *
  34178. * <aside class="is-right">
  34179. * Note that unlike other lifecycle hooks, this one uses an annotation rather than an interface.
  34180. * This is because the `CanActivate` function is called before the component is instantiated.
  34181. * </aside>
  34182. *
  34183. * The `CanActivate` hook is called with two {@link ComponentInstruction}s as parameters, the first
  34184. * representing the current route being navigated to, and the second parameter representing the
  34185. * previous route or `null`.
  34186. *
  34187. * ```typescript
  34188. * @CanActivate((next, prev) => boolean | Promise<boolean>)
  34189. * ```
  34190. *
  34191. * If `CanActivate` returns or resolves to `false`, the navigation is cancelled.
  34192. * If `CanActivate` throws or rejects, the navigation is also cancelled.
  34193. * If `CanActivate` returns or resolves to `true`, navigation continues, the component is
  34194. * instantiated, and the {@link OnActivate} hook of that component is called if implemented.
  34195. *
  34196. * ### Example
  34197. *
  34198. * {@example router/ts/can_activate/can_activate_example.ts region='canActivate' }
  34199. */
  34200. exports.CanActivate = decorators_1.makeDecorator(lifecycle_annotations_impl_1.CanActivate);
  34201. /***/ },
  34202. /* 243 */
  34203. /***/ function(module, exports, __webpack_require__) {
  34204. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  34205. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34206. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34207. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  34208. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34209. };
  34210. var __metadata = (this && this.__metadata) || function (k, v) {
  34211. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  34212. };
  34213. var core_1 = __webpack_require__(2);
  34214. var lang_1 = __webpack_require__(5);
  34215. var router_1 = __webpack_require__(225);
  34216. var location_1 = __webpack_require__(237);
  34217. /**
  34218. * The RouterLink directive lets you link to specific parts of your app.
  34219. *
  34220. * Consider the following route configuration:
  34221. * ```
  34222. * @RouteConfig([
  34223. * { path: '/user', component: UserCmp, as: 'User' }
  34224. * ]);
  34225. * class MyComp {}
  34226. * ```
  34227. *
  34228. * When linking to this `User` route, you can write:
  34229. *
  34230. * ```
  34231. * <a [routerLink]="['./User']">link to user component</a>
  34232. * ```
  34233. *
  34234. * RouterLink expects the value to be an array of route names, followed by the params
  34235. * for that level of routing. For instance `['/Team', {teamId: 1}, 'User', {userId: 2}]`
  34236. * means that we want to generate a link for the `Team` route with params `{teamId: 1}`,
  34237. * and with a child route `User` with params `{userId: 2}`.
  34238. *
  34239. * The first route name should be prepended with `/`, `./`, or `../`.
  34240. * If the route begins with `/`, the router will look up the route from the root of the app.
  34241. * If the route begins with `./`, the router will instead look in the current component's
  34242. * children for the route. And if the route begins with `../`, the router will look at the
  34243. * current component's parent.
  34244. */
  34245. var RouterLink = (function () {
  34246. function RouterLink(_router, _location) {
  34247. this._router = _router;
  34248. this._location = _location;
  34249. }
  34250. Object.defineProperty(RouterLink.prototype, "isRouteActive", {
  34251. get: function () { return this._router.isRouteActive(this._navigationInstruction); },
  34252. enumerable: true,
  34253. configurable: true
  34254. });
  34255. Object.defineProperty(RouterLink.prototype, "routeParams", {
  34256. set: function (changes) {
  34257. this._routeParams = changes;
  34258. this._navigationInstruction = this._router.generate(this._routeParams);
  34259. var navigationHref = this._navigationInstruction.toLinkUrl();
  34260. this.visibleHref = this._location.prepareExternalUrl(navigationHref);
  34261. },
  34262. enumerable: true,
  34263. configurable: true
  34264. });
  34265. RouterLink.prototype.onClick = function () {
  34266. // If no target, or if target is _self, prevent default browser behavior
  34267. if (!lang_1.isString(this.target) || this.target == '_self') {
  34268. this._router.navigateByInstruction(this._navigationInstruction);
  34269. return false;
  34270. }
  34271. return true;
  34272. };
  34273. RouterLink = __decorate([
  34274. core_1.Directive({
  34275. selector: '[routerLink]',
  34276. inputs: ['routeParams: routerLink', 'target: target'],
  34277. host: {
  34278. '(click)': 'onClick()',
  34279. '[attr.href]': 'visibleHref',
  34280. '[class.router-link-active]': 'isRouteActive'
  34281. }
  34282. }),
  34283. __metadata('design:paramtypes', [router_1.Router, location_1.Location])
  34284. ], RouterLink);
  34285. return RouterLink;
  34286. })();
  34287. exports.RouterLink = RouterLink;
  34288. /***/ },
  34289. /* 244 */
  34290. /***/ function(module, exports, __webpack_require__) {
  34291. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  34292. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34293. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34294. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  34295. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34296. };
  34297. var __metadata = (this && this.__metadata) || function (k, v) {
  34298. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  34299. };
  34300. var dom_adapter_1 = __webpack_require__(178);
  34301. var core_1 = __webpack_require__(2);
  34302. /**
  34303. * `PlatformLocation` encapsulates all of the direct calls to platform APIs.
  34304. * This class should not be used directly by an application developer. Instead, use
  34305. * {@link Location}.
  34306. */
  34307. var PlatformLocation = (function () {
  34308. function PlatformLocation() {
  34309. this._init();
  34310. }
  34311. // This is moved to its own method so that `MockPlatformLocationStrategy` can overwrite it
  34312. /** @internal */
  34313. PlatformLocation.prototype._init = function () {
  34314. this._location = dom_adapter_1.DOM.getLocation();
  34315. this._history = dom_adapter_1.DOM.getHistory();
  34316. };
  34317. PlatformLocation.prototype.getBaseHrefFromDOM = function () { return dom_adapter_1.DOM.getBaseHref(); };
  34318. PlatformLocation.prototype.onPopState = function (fn) {
  34319. dom_adapter_1.DOM.getGlobalEventTarget('window').addEventListener('popstate', fn, false);
  34320. };
  34321. PlatformLocation.prototype.onHashChange = function (fn) {
  34322. dom_adapter_1.DOM.getGlobalEventTarget('window').addEventListener('hashchange', fn, false);
  34323. };
  34324. Object.defineProperty(PlatformLocation.prototype, "pathname", {
  34325. get: function () { return this._location.pathname; },
  34326. set: function (newPath) { this._location.pathname = newPath; },
  34327. enumerable: true,
  34328. configurable: true
  34329. });
  34330. Object.defineProperty(PlatformLocation.prototype, "search", {
  34331. get: function () { return this._location.search; },
  34332. enumerable: true,
  34333. configurable: true
  34334. });
  34335. Object.defineProperty(PlatformLocation.prototype, "hash", {
  34336. get: function () { return this._location.hash; },
  34337. enumerable: true,
  34338. configurable: true
  34339. });
  34340. PlatformLocation.prototype.pushState = function (state, title, url) {
  34341. this._history.pushState(state, title, url);
  34342. };
  34343. PlatformLocation.prototype.replaceState = function (state, title, url) {
  34344. this._history.replaceState(state, title, url);
  34345. };
  34346. PlatformLocation.prototype.forward = function () { this._history.forward(); };
  34347. PlatformLocation.prototype.back = function () { this._history.back(); };
  34348. PlatformLocation = __decorate([
  34349. core_1.Injectable(),
  34350. __metadata('design:paramtypes', [])
  34351. ], PlatformLocation);
  34352. return PlatformLocation;
  34353. })();
  34354. exports.PlatformLocation = PlatformLocation;
  34355. /***/ },
  34356. /* 245 */
  34357. /***/ function(module, exports, __webpack_require__) {
  34358. var __extends = (this && this.__extends) || function (d, b) {
  34359. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  34360. function __() { this.constructor = d; }
  34361. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34362. };
  34363. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  34364. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34365. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34366. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  34367. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34368. };
  34369. var __metadata = (this && this.__metadata) || function (k, v) {
  34370. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  34371. };
  34372. var __param = (this && this.__param) || function (paramIndex, decorator) {
  34373. return function (target, key) { decorator(target, key, paramIndex); }
  34374. };
  34375. var core_1 = __webpack_require__(2);
  34376. var location_strategy_1 = __webpack_require__(238);
  34377. var lang_1 = __webpack_require__(5);
  34378. var platform_location_1 = __webpack_require__(244);
  34379. /**
  34380. * `HashLocationStrategy` is a {@link LocationStrategy} used to configure the
  34381. * {@link Location} service to represent its state in the
  34382. * [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax)
  34383. * of the browser's URL.
  34384. *
  34385. * For instance, if you call `location.go('/foo')`, the browser's URL will become
  34386. * `example.com#/foo`.
  34387. *
  34388. * ### Example
  34389. *
  34390. * ```
  34391. * import {Component, provide} from 'angular2/core';
  34392. * import {
  34393. * ROUTER_DIRECTIVES,
  34394. * ROUTER_PROVIDERS,
  34395. * RouteConfig,
  34396. * Location,
  34397. * LocationStrategy,
  34398. * HashLocationStrategy
  34399. * } from 'angular2/router';
  34400. *
  34401. * @Component({directives: [ROUTER_DIRECTIVES]})
  34402. * @RouteConfig([
  34403. * {...},
  34404. * ])
  34405. * class AppCmp {
  34406. * constructor(location: Location) {
  34407. * location.go('/foo');
  34408. * }
  34409. * }
  34410. *
  34411. * bootstrap(AppCmp, [
  34412. * ROUTER_PROVIDERS,
  34413. * provide(LocationStrategy, {useClass: HashLocationStrategy})
  34414. * ]);
  34415. * ```
  34416. */
  34417. var HashLocationStrategy = (function (_super) {
  34418. __extends(HashLocationStrategy, _super);
  34419. function HashLocationStrategy(_platformLocation, _baseHref) {
  34420. _super.call(this);
  34421. this._platformLocation = _platformLocation;
  34422. this._baseHref = '';
  34423. if (lang_1.isPresent(_baseHref)) {
  34424. this._baseHref = _baseHref;
  34425. }
  34426. }
  34427. HashLocationStrategy.prototype.onPopState = function (fn) {
  34428. this._platformLocation.onPopState(fn);
  34429. this._platformLocation.onHashChange(fn);
  34430. };
  34431. HashLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; };
  34432. HashLocationStrategy.prototype.path = function () {
  34433. // the hash value is always prefixed with a `#`
  34434. // and if it is empty then it will stay empty
  34435. var path = this._platformLocation.hash;
  34436. // Dart will complain if a call to substring is
  34437. // executed with a position value that extends the
  34438. // length of string.
  34439. return (path.length > 0 ? path.substring(1) : path) +
  34440. location_strategy_1.normalizeQueryParams(this._platformLocation.search);
  34441. };
  34442. HashLocationStrategy.prototype.prepareExternalUrl = function (internal) {
  34443. var url = location_strategy_1.joinWithSlash(this._baseHref, internal);
  34444. return url.length > 0 ? ('#' + url) : url;
  34445. };
  34446. HashLocationStrategy.prototype.pushState = function (state, title, path, queryParams) {
  34447. var url = this.prepareExternalUrl(path + location_strategy_1.normalizeQueryParams(queryParams));
  34448. if (url.length == 0) {
  34449. url = this._platformLocation.pathname;
  34450. }
  34451. this._platformLocation.pushState(state, title, url);
  34452. };
  34453. HashLocationStrategy.prototype.replaceState = function (state, title, path, queryParams) {
  34454. var url = this.prepareExternalUrl(path + location_strategy_1.normalizeQueryParams(queryParams));
  34455. if (url.length == 0) {
  34456. url = this._platformLocation.pathname;
  34457. }
  34458. this._platformLocation.replaceState(state, title, url);
  34459. };
  34460. HashLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); };
  34461. HashLocationStrategy.prototype.back = function () { this._platformLocation.back(); };
  34462. HashLocationStrategy = __decorate([
  34463. core_1.Injectable(),
  34464. __param(1, core_1.Optional()),
  34465. __param(1, core_1.Inject(location_strategy_1.APP_BASE_HREF)),
  34466. __metadata('design:paramtypes', [platform_location_1.PlatformLocation, String])
  34467. ], HashLocationStrategy);
  34468. return HashLocationStrategy;
  34469. })(location_strategy_1.LocationStrategy);
  34470. exports.HashLocationStrategy = HashLocationStrategy;
  34471. /***/ },
  34472. /* 246 */
  34473. /***/ function(module, exports, __webpack_require__) {
  34474. var __extends = (this && this.__extends) || function (d, b) {
  34475. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  34476. function __() { this.constructor = d; }
  34477. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34478. };
  34479. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  34480. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34481. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34482. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  34483. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34484. };
  34485. var __metadata = (this && this.__metadata) || function (k, v) {
  34486. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  34487. };
  34488. var __param = (this && this.__param) || function (paramIndex, decorator) {
  34489. return function (target, key) { decorator(target, key, paramIndex); }
  34490. };
  34491. var core_1 = __webpack_require__(2);
  34492. var lang_1 = __webpack_require__(5);
  34493. var exceptions_1 = __webpack_require__(14);
  34494. var location_strategy_1 = __webpack_require__(238);
  34495. var platform_location_1 = __webpack_require__(244);
  34496. /**
  34497. * `PathLocationStrategy` is a {@link LocationStrategy} used to configure the
  34498. * {@link Location} service to represent its state in the
  34499. * [path](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) of the
  34500. * browser's URL.
  34501. *
  34502. * `PathLocationStrategy` is the default binding for {@link LocationStrategy}
  34503. * provided in {@link ROUTER_PROVIDERS}.
  34504. *
  34505. * If you're using `PathLocationStrategy`, you must provide a provider for
  34506. * {@link APP_BASE_HREF} to a string representing the URL prefix that should
  34507. * be preserved when generating and recognizing URLs.
  34508. *
  34509. * For instance, if you provide an `APP_BASE_HREF` of `'/my/app'` and call
  34510. * `location.go('/foo')`, the browser's URL will become
  34511. * `example.com/my/app/foo`.
  34512. *
  34513. * ### Example
  34514. *
  34515. * ```
  34516. * import {Component, provide} from 'angular2/core';
  34517. * import {
  34518. * APP_BASE_HREF
  34519. * ROUTER_DIRECTIVES,
  34520. * ROUTER_PROVIDERS,
  34521. * RouteConfig,
  34522. * Location
  34523. * } from 'angular2/router';
  34524. *
  34525. * @Component({directives: [ROUTER_DIRECTIVES]})
  34526. * @RouteConfig([
  34527. * {...},
  34528. * ])
  34529. * class AppCmp {
  34530. * constructor(location: Location) {
  34531. * location.go('/foo');
  34532. * }
  34533. * }
  34534. *
  34535. * bootstrap(AppCmp, [
  34536. * ROUTER_PROVIDERS, // includes binding to PathLocationStrategy
  34537. * provide(APP_BASE_HREF, {useValue: '/my/app'})
  34538. * ]);
  34539. * ```
  34540. */
  34541. var PathLocationStrategy = (function (_super) {
  34542. __extends(PathLocationStrategy, _super);
  34543. function PathLocationStrategy(_platformLocation, href) {
  34544. _super.call(this);
  34545. this._platformLocation = _platformLocation;
  34546. if (lang_1.isBlank(href)) {
  34547. href = this._platformLocation.getBaseHrefFromDOM();
  34548. }
  34549. if (lang_1.isBlank(href)) {
  34550. throw new exceptions_1.BaseException("No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.");
  34551. }
  34552. this._baseHref = href;
  34553. }
  34554. PathLocationStrategy.prototype.onPopState = function (fn) {
  34555. this._platformLocation.onPopState(fn);
  34556. this._platformLocation.onHashChange(fn);
  34557. };
  34558. PathLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; };
  34559. PathLocationStrategy.prototype.prepareExternalUrl = function (internal) { return location_strategy_1.joinWithSlash(this._baseHref, internal); };
  34560. PathLocationStrategy.prototype.path = function () {
  34561. return this._platformLocation.pathname + location_strategy_1.normalizeQueryParams(this._platformLocation.search);
  34562. };
  34563. PathLocationStrategy.prototype.pushState = function (state, title, url, queryParams) {
  34564. var externalUrl = this.prepareExternalUrl(url + location_strategy_1.normalizeQueryParams(queryParams));
  34565. this._platformLocation.pushState(state, title, externalUrl);
  34566. };
  34567. PathLocationStrategy.prototype.replaceState = function (state, title, url, queryParams) {
  34568. var externalUrl = this.prepareExternalUrl(url + location_strategy_1.normalizeQueryParams(queryParams));
  34569. this._platformLocation.replaceState(state, title, externalUrl);
  34570. };
  34571. PathLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); };
  34572. PathLocationStrategy.prototype.back = function () { this._platformLocation.back(); };
  34573. PathLocationStrategy = __decorate([
  34574. core_1.Injectable(),
  34575. __param(1, core_1.Optional()),
  34576. __param(1, core_1.Inject(location_strategy_1.APP_BASE_HREF)),
  34577. __metadata('design:paramtypes', [platform_location_1.PlatformLocation, String])
  34578. ], PathLocationStrategy);
  34579. return PathLocationStrategy;
  34580. })(location_strategy_1.LocationStrategy);
  34581. exports.PathLocationStrategy = PathLocationStrategy;
  34582. /***/ },
  34583. /* 247 */
  34584. /***/ function(module, exports) {
  34585. /***/ },
  34586. /* 248 */
  34587. /***/ function(module, exports, __webpack_require__) {
  34588. var compiler_1 = __webpack_require__(147);
  34589. var core_1 = __webpack_require__(2);
  34590. var router_link_transform_1 = __webpack_require__(249);
  34591. var lang_1 = __webpack_require__(5);
  34592. var router_link_transform_2 = __webpack_require__(249);
  34593. exports.RouterLinkTransform = router_link_transform_2.RouterLinkTransform;
  34594. /**
  34595. * Enables the router link DSL.
  34596. *
  34597. * Warning. This feature is experimental and can change.
  34598. *
  34599. * To enable the transformer pass the router link DSL provider to `bootstrap`.
  34600. *
  34601. * ## Example:
  34602. * ```
  34603. * import {bootstrap} from 'angular2/platform/browser';
  34604. * import {ROUTER_LINK_DSL_PROVIDER} from 'angular2/router/router_link_dsl';
  34605. *
  34606. * bootstrap(CustomApp, [ROUTER_LINK_DSL_PROVIDER]);
  34607. * ```
  34608. *
  34609. * The DSL allows you to express router links as follows:
  34610. * ```
  34611. * <a [routerLink]="route:User"> <!-- Same as <a [routerLink]="['User']"> -->
  34612. * <a [routerLink]="route:/User"> <!-- Same as <a [routerLink]="['User']"> -->
  34613. * <a [routerLink]="route:./User"> <!-- Same as <a [routerLink]="['./User']"> -->
  34614. * <a [routerLink]="./User(id: value, name: 'Bob')"> <!-- Same as <a [routerLink]="['./User', {id:
  34615. * value, name: 'Bob'}]"> -->
  34616. * <a [routerLink]="/User/Modal"> <!-- Same as <a [routerLink]="['/User', 'Modal']"> -->
  34617. * <a [routerLink]="User[Modal]"> <!-- Same as <a [routerLink]="['User', ['Modal']]"> -->
  34618. * ```
  34619. */
  34620. exports.ROUTER_LINK_DSL_PROVIDER = lang_1.CONST_EXPR(new core_1.Provider(compiler_1.TEMPLATE_TRANSFORMS, { useClass: router_link_transform_1.RouterLinkTransform, multi: true }));
  34621. /***/ },
  34622. /* 249 */
  34623. /***/ function(module, exports, __webpack_require__) {
  34624. var __extends = (this && this.__extends) || function (d, b) {
  34625. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  34626. function __() { this.constructor = d; }
  34627. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34628. };
  34629. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  34630. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34631. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34632. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  34633. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34634. };
  34635. var __metadata = (this && this.__metadata) || function (k, v) {
  34636. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  34637. };
  34638. var compiler_1 = __webpack_require__(147);
  34639. var ast_1 = __webpack_require__(30);
  34640. var exceptions_1 = __webpack_require__(14);
  34641. var core_1 = __webpack_require__(2);
  34642. var parser_1 = __webpack_require__(32);
  34643. /**
  34644. * e.g., './User', 'Modal' in ./User[Modal(param: value)]
  34645. */
  34646. var FixedPart = (function () {
  34647. function FixedPart(value) {
  34648. this.value = value;
  34649. }
  34650. return FixedPart;
  34651. })();
  34652. /**
  34653. * The square bracket
  34654. */
  34655. var AuxiliaryStart = (function () {
  34656. function AuxiliaryStart() {
  34657. }
  34658. return AuxiliaryStart;
  34659. })();
  34660. /**
  34661. * The square bracket
  34662. */
  34663. var AuxiliaryEnd = (function () {
  34664. function AuxiliaryEnd() {
  34665. }
  34666. return AuxiliaryEnd;
  34667. })();
  34668. /**
  34669. * e.g., param:value in ./User[Modal(param: value)]
  34670. */
  34671. var Params = (function () {
  34672. function Params(ast) {
  34673. this.ast = ast;
  34674. }
  34675. return Params;
  34676. })();
  34677. var RouterLinkLexer = (function () {
  34678. function RouterLinkLexer(parser, exp) {
  34679. this.parser = parser;
  34680. this.exp = exp;
  34681. this.index = 0;
  34682. }
  34683. RouterLinkLexer.prototype.tokenize = function () {
  34684. var tokens = [];
  34685. while (this.index < this.exp.length) {
  34686. tokens.push(this._parseToken());
  34687. }
  34688. return tokens;
  34689. };
  34690. RouterLinkLexer.prototype._parseToken = function () {
  34691. var c = this.exp[this.index];
  34692. if (c == '[') {
  34693. this.index++;
  34694. return new AuxiliaryStart();
  34695. }
  34696. else if (c == ']') {
  34697. this.index++;
  34698. return new AuxiliaryEnd();
  34699. }
  34700. else if (c == '(') {
  34701. return this._parseParams();
  34702. }
  34703. else if (c == '/' && this.index !== 0) {
  34704. this.index++;
  34705. return this._parseFixedPart();
  34706. }
  34707. else {
  34708. return this._parseFixedPart();
  34709. }
  34710. };
  34711. RouterLinkLexer.prototype._parseParams = function () {
  34712. var start = this.index;
  34713. for (; this.index < this.exp.length; ++this.index) {
  34714. var c = this.exp[this.index];
  34715. if (c == ')') {
  34716. var paramsContent = this.exp.substring(start + 1, this.index);
  34717. this.index++;
  34718. return new Params(this.parser.parseBinding("{" + paramsContent + "}", null).ast);
  34719. }
  34720. }
  34721. throw new exceptions_1.BaseException("Cannot find ')'");
  34722. };
  34723. RouterLinkLexer.prototype._parseFixedPart = function () {
  34724. var start = this.index;
  34725. var sawNonSlash = false;
  34726. for (; this.index < this.exp.length; ++this.index) {
  34727. var c = this.exp[this.index];
  34728. if (c == '(' || c == '[' || c == ']' || (c == '/' && sawNonSlash)) {
  34729. break;
  34730. }
  34731. if (c != '.' && c != '/') {
  34732. sawNonSlash = true;
  34733. }
  34734. }
  34735. var fixed = this.exp.substring(start, this.index);
  34736. if (start === this.index || !sawNonSlash || fixed.startsWith('//')) {
  34737. throw new exceptions_1.BaseException("Invalid router link");
  34738. }
  34739. return new FixedPart(fixed);
  34740. };
  34741. return RouterLinkLexer;
  34742. })();
  34743. var RouterLinkAstGenerator = (function () {
  34744. function RouterLinkAstGenerator(tokens) {
  34745. this.tokens = tokens;
  34746. this.index = 0;
  34747. }
  34748. RouterLinkAstGenerator.prototype.generate = function () { return this._genAuxiliary(); };
  34749. RouterLinkAstGenerator.prototype._genAuxiliary = function () {
  34750. var arr = [];
  34751. for (; this.index < this.tokens.length; this.index++) {
  34752. var r = this.tokens[this.index];
  34753. if (r instanceof FixedPart) {
  34754. arr.push(new ast_1.LiteralPrimitive(r.value));
  34755. }
  34756. else if (r instanceof Params) {
  34757. arr.push(r.ast);
  34758. }
  34759. else if (r instanceof AuxiliaryEnd) {
  34760. break;
  34761. }
  34762. else if (r instanceof AuxiliaryStart) {
  34763. this.index++;
  34764. arr.push(this._genAuxiliary());
  34765. }
  34766. }
  34767. return new ast_1.LiteralArray(arr);
  34768. };
  34769. return RouterLinkAstGenerator;
  34770. })();
  34771. var RouterLinkAstTransformer = (function (_super) {
  34772. __extends(RouterLinkAstTransformer, _super);
  34773. function RouterLinkAstTransformer(parser) {
  34774. _super.call(this);
  34775. this.parser = parser;
  34776. }
  34777. RouterLinkAstTransformer.prototype.visitQuote = function (ast) {
  34778. if (ast.prefix == "route") {
  34779. return parseRouterLinkExpression(this.parser, ast.uninterpretedExpression);
  34780. }
  34781. else {
  34782. return _super.prototype.visitQuote.call(this, ast);
  34783. }
  34784. };
  34785. return RouterLinkAstTransformer;
  34786. })(ast_1.AstTransformer);
  34787. function parseRouterLinkExpression(parser, exp) {
  34788. var tokens = new RouterLinkLexer(parser, exp.trim()).tokenize();
  34789. return new RouterLinkAstGenerator(tokens).generate();
  34790. }
  34791. exports.parseRouterLinkExpression = parseRouterLinkExpression;
  34792. /**
  34793. * A compiler plugin that implements the router link DSL.
  34794. */
  34795. var RouterLinkTransform = (function () {
  34796. function RouterLinkTransform(parser) {
  34797. this.astTransformer = new RouterLinkAstTransformer(parser);
  34798. }
  34799. RouterLinkTransform.prototype.visitNgContent = function (ast, context) { return ast; };
  34800. RouterLinkTransform.prototype.visitEmbeddedTemplate = function (ast, context) { return ast; };
  34801. RouterLinkTransform.prototype.visitElement = function (ast, context) {
  34802. var _this = this;
  34803. var updatedChildren = ast.children.map(function (c) { return c.visit(_this, context); });
  34804. var updatedInputs = ast.inputs.map(function (c) { return c.visit(_this, context); });
  34805. var updatedDirectives = ast.directives.map(function (c) { return c.visit(_this, context); });
  34806. return new compiler_1.ElementAst(ast.name, ast.attrs, updatedInputs, ast.outputs, ast.exportAsVars, updatedDirectives, updatedChildren, ast.ngContentIndex, ast.sourceSpan);
  34807. };
  34808. RouterLinkTransform.prototype.visitVariable = function (ast, context) { return ast; };
  34809. RouterLinkTransform.prototype.visitEvent = function (ast, context) { return ast; };
  34810. RouterLinkTransform.prototype.visitElementProperty = function (ast, context) { return ast; };
  34811. RouterLinkTransform.prototype.visitAttr = function (ast, context) { return ast; };
  34812. RouterLinkTransform.prototype.visitBoundText = function (ast, context) { return ast; };
  34813. RouterLinkTransform.prototype.visitText = function (ast, context) { return ast; };
  34814. RouterLinkTransform.prototype.visitDirective = function (ast, context) {
  34815. var _this = this;
  34816. var updatedInputs = ast.inputs.map(function (c) { return c.visit(_this, context); });
  34817. return new compiler_1.DirectiveAst(ast.directive, updatedInputs, ast.hostProperties, ast.hostEvents, ast.exportAsVars, ast.sourceSpan);
  34818. };
  34819. RouterLinkTransform.prototype.visitDirectiveProperty = function (ast, context) {
  34820. var transformedValue = ast.value.visit(this.astTransformer);
  34821. return new compiler_1.BoundDirectivePropertyAst(ast.directiveName, ast.templateName, transformedValue, ast.sourceSpan);
  34822. };
  34823. RouterLinkTransform = __decorate([
  34824. core_1.Injectable(),
  34825. __metadata('design:paramtypes', [parser_1.Parser])
  34826. ], RouterLinkTransform);
  34827. return RouterLinkTransform;
  34828. })();
  34829. exports.RouterLinkTransform = RouterLinkTransform;
  34830. /***/ },
  34831. /* 250 */
  34832. /***/ function(module, exports, __webpack_require__) {
  34833. var profile_1 = __webpack_require__(45);
  34834. exports.wtfCreateScope = profile_1.wtfCreateScope;
  34835. exports.wtfLeave = profile_1.wtfLeave;
  34836. exports.wtfStartTimeRange = profile_1.wtfStartTimeRange;
  34837. exports.wtfEndTimeRange = profile_1.wtfEndTimeRange;
  34838. /***/ },
  34839. /* 251 */
  34840. /***/ function(module, exports, __webpack_require__) {
  34841. /**
  34842. * @module
  34843. * @description
  34844. * Adapter allowing AngularJS v1 and Angular v2 to run side by side in the same application.
  34845. */
  34846. var upgrade_adapter_1 = __webpack_require__(252);
  34847. exports.UpgradeAdapter = upgrade_adapter_1.UpgradeAdapter;
  34848. exports.UpgradeAdapterRef = upgrade_adapter_1.UpgradeAdapterRef;
  34849. /***/ },
  34850. /* 252 */
  34851. /***/ function(module, exports, __webpack_require__) {
  34852. var core_1 = __webpack_require__(2);
  34853. var async_1 = __webpack_require__(60);
  34854. var browser_1 = __webpack_require__(179);
  34855. var metadata_1 = __webpack_require__(253);
  34856. var util_1 = __webpack_require__(254);
  34857. var constants_1 = __webpack_require__(255);
  34858. var downgrade_ng2_adapter_1 = __webpack_require__(256);
  34859. var upgrade_ng1_adapter_1 = __webpack_require__(257);
  34860. var angular = __webpack_require__(258);
  34861. var upgradeCount = 0;
  34862. /**
  34863. * Use `UpgradeAdapter` to allow AngularJS v1 and Angular v2 to coexist in a single application.
  34864. *
  34865. * The `UpgradeAdapter` allows:
  34866. * 1. creation of Angular v2 component from AngularJS v1 component directive
  34867. * (See [UpgradeAdapter#upgradeNg1Component()])
  34868. * 2. creation of AngularJS v1 directive from Angular v2 component.
  34869. * (See [UpgradeAdapter#downgradeNg2Component()])
  34870. * 3. Bootstrapping of a hybrid Angular application which contains both of the frameworks
  34871. * coexisting in a single application.
  34872. *
  34873. * ## Mental Model
  34874. *
  34875. * When reasoning about how a hybrid application works it is useful to have a mental model which
  34876. * describes what is happening and explains what is happening at the lowest level.
  34877. *
  34878. * 1. There are two independent frameworks running in a single application, each framework treats
  34879. * the other as a black box.
  34880. * 2. Each DOM element on the page is owned exactly by one framework. Whichever framework
  34881. * instantiated the element is the owner. Each framework only updates/interacts with its own
  34882. * DOM elements and ignores others.
  34883. * 3. AngularJS v1 directives always execute inside AngularJS v1 framework codebase regardless of
  34884. * where they are instantiated.
  34885. * 4. Angular v2 components always execute inside Angular v2 framework codebase regardless of
  34886. * where they are instantiated.
  34887. * 5. An AngularJS v1 component can be upgraded to an Angular v2 component. This creates an
  34888. * Angular v2 directive, which bootstraps the AngularJS v1 component directive in that location.
  34889. * 6. An Angular v2 component can be downgraded to an AngularJS v1 component directive. This creates
  34890. * an AngularJS v1 directive, which bootstraps the Angular v2 component in that location.
  34891. * 7. Whenever an adapter component is instantiated the host element is owned by the framework
  34892. * doing the instantiation. The other framework then instantiates and owns the view for that
  34893. * component. This implies that component bindings will always follow the semantics of the
  34894. * instantiation framework. The syntax is always that of Angular v2 syntax.
  34895. * 8. AngularJS v1 is always bootstrapped first and owns the bottom most view.
  34896. * 9. The new application is running in Angular v2 zone, and therefore it no longer needs calls to
  34897. * `$apply()`.
  34898. *
  34899. * ### Example
  34900. *
  34901. * ```
  34902. * var adapter = new UpgradeAdapter();
  34903. * var module = angular.module('myExample', []);
  34904. * module.directive('ng2', adapter.downgradeNg2Component(Ng2));
  34905. *
  34906. * module.directive('ng1', function() {
  34907. * return {
  34908. * scope: { title: '=' },
  34909. * template: 'ng1[Hello {{title}}!](<span ng-transclude></span>)'
  34910. * };
  34911. * });
  34912. *
  34913. *
  34914. * @Component({
  34915. * selector: 'ng2',
  34916. * inputs: ['name'],
  34917. * template: 'ng2[<ng1 [title]="name">transclude</ng1>](<ng-content></ng-content>)',
  34918. * directives: [adapter.upgradeNg1Component('ng1')]
  34919. * })
  34920. * class Ng2 {
  34921. * }
  34922. *
  34923. * document.body.innerHTML = '<ng2 name="World">project</ng2>';
  34924. *
  34925. * adapter.bootstrap(document.body, ['myExample']).ready(function() {
  34926. * expect(document.body.textContent).toEqual(
  34927. * "ng2[ng1[Hello World!](transclude)](project)");
  34928. * });
  34929. * ```
  34930. */
  34931. var UpgradeAdapter = (function () {
  34932. function UpgradeAdapter() {
  34933. /* @internal */
  34934. this.idPrefix = "NG2_UPGRADE_" + upgradeCount++ + "_";
  34935. /* @internal */
  34936. this.upgradedComponents = [];
  34937. /* @internal */
  34938. this.downgradedComponents = {};
  34939. /* @internal */
  34940. this.providers = [];
  34941. }
  34942. /**
  34943. * Allows Angular v2 Component to be used from AngularJS v1.
  34944. *
  34945. * Use `downgradeNg2Component` to create an AngularJS v1 Directive Definition Factory from
  34946. * Angular v2 Component. The adapter will bootstrap Angular v2 component from within the
  34947. * AngularJS v1 template.
  34948. *
  34949. * ## Mental Model
  34950. *
  34951. * 1. The component is instantiated by being listed in AngularJS v1 template. This means that the
  34952. * host element is controlled by AngularJS v1, but the component's view will be controlled by
  34953. * Angular v2.
  34954. * 2. Even thought the component is instantiated in AngularJS v1, it will be using Angular v2
  34955. * syntax. This has to be done, this way because we must follow Angular v2 components do not
  34956. * declare how the attributes should be interpreted.
  34957. *
  34958. * ## Supported Features
  34959. *
  34960. * - Bindings:
  34961. * - Attribute: `<comp name="World">`
  34962. * - Interpolation: `<comp greeting="Hello {{name}}!">`
  34963. * - Expression: `<comp [name]="username">`
  34964. * - Event: `<comp (close)="doSomething()">`
  34965. * - Content projection: yes
  34966. *
  34967. * ### Example
  34968. *
  34969. * ```
  34970. * var adapter = new UpgradeAdapter();
  34971. * var module = angular.module('myExample', []);
  34972. * module.directive('greet', adapter.downgradeNg2Component(Greeter));
  34973. *
  34974. * @Component({
  34975. * selector: 'greet',
  34976. * template: '{{salutation}} {{name}}! - <ng-content></ng-content>'
  34977. * })
  34978. * class Greeter {
  34979. * @Input() salutation: string;
  34980. * @Input() name: string;
  34981. * }
  34982. *
  34983. * document.body.innerHTML =
  34984. * 'ng1 template: <greet salutation="Hello" [name]="world">text</greet>';
  34985. *
  34986. * adapter.bootstrap(document.body, ['myExample']).ready(function() {
  34987. * expect(document.body.textContent).toEqual("ng1 template: Hello world! - text");
  34988. * });
  34989. * ```
  34990. */
  34991. UpgradeAdapter.prototype.downgradeNg2Component = function (type) {
  34992. this.upgradedComponents.push(type);
  34993. var info = metadata_1.getComponentInfo(type);
  34994. return ng1ComponentDirective(info, "" + this.idPrefix + info.selector + "_c");
  34995. };
  34996. /**
  34997. * Allows AngularJS v1 Component to be used from Angular v2.
  34998. *
  34999. * Use `upgradeNg1Component` to create an Angular v2 component from AngularJS v1 Component
  35000. * directive. The adapter will bootstrap AngularJS v1 component from within the Angular v2
  35001. * template.
  35002. *
  35003. * ## Mental Model
  35004. *
  35005. * 1. The component is instantiated by being listed in Angular v2 template. This means that the
  35006. * host element is controlled by Angular v2, but the component's view will be controlled by
  35007. * AngularJS v1.
  35008. *
  35009. * ## Supported Features
  35010. *
  35011. * - Bindings:
  35012. * - Attribute: `<comp name="World">`
  35013. * - Interpolation: `<comp greeting="Hello {{name}}!">`
  35014. * - Expression: `<comp [name]="username">`
  35015. * - Event: `<comp (close)="doSomething()">`
  35016. * - Transclusion: yes
  35017. * - Only some of the features of
  35018. * [Directive Definition Object](https://docs.angularjs.org/api/ng/service/$compile) are
  35019. * supported:
  35020. * - `compile`: not supported because the host element is owned by Angular v2, which does
  35021. * not allow modifying DOM structure during compilation.
  35022. * - `controller`: supported. (NOTE: injection of `$attrs` and `$transclude` is not supported.)
  35023. * - `controllerAs': supported.
  35024. * - `bindToController': supported.
  35025. * - `link': supported. (NOTE: only pre-link function is supported.)
  35026. * - `name': supported.
  35027. * - `priority': ignored.
  35028. * - `replace': not supported.
  35029. * - `require`: supported.
  35030. * - `restrict`: must be set to 'E'.
  35031. * - `scope`: supported.
  35032. * - `template`: supported.
  35033. * - `templateUrl`: supported.
  35034. * - `terminal`: ignored.
  35035. * - `transclude`: supported.
  35036. *
  35037. *
  35038. * ### Example
  35039. *
  35040. * ```
  35041. * var adapter = new UpgradeAdapter();
  35042. * var module = angular.module('myExample', []);
  35043. *
  35044. * module.directive('greet', function() {
  35045. * return {
  35046. * scope: {salutation: '=', name: '=' },
  35047. * template: '{{salutation}} {{name}}! - <span ng-transclude></span>'
  35048. * };
  35049. * });
  35050. *
  35051. * module.directive('ng2', adapter.downgradeNg2Component(Ng2));
  35052. *
  35053. * @Component({
  35054. * selector: 'ng2',
  35055. * template: 'ng2 template: <greet salutation="Hello" [name]="world">text</greet>'
  35056. * directives: [adapter.upgradeNg1Component('greet')]
  35057. * })
  35058. * class Ng2 {
  35059. * }
  35060. *
  35061. * document.body.innerHTML = '<ng2></ng2>';
  35062. *
  35063. * adapter.bootstrap(document.body, ['myExample']).ready(function() {
  35064. * expect(document.body.textContent).toEqual("ng2 template: Hello world! - text");
  35065. * });
  35066. * ```
  35067. */
  35068. UpgradeAdapter.prototype.upgradeNg1Component = function (name) {
  35069. if (this.downgradedComponents.hasOwnProperty(name)) {
  35070. return this.downgradedComponents[name].type;
  35071. }
  35072. else {
  35073. return (this.downgradedComponents[name] = new upgrade_ng1_adapter_1.UpgradeNg1ComponentAdapterBuilder(name)).type;
  35074. }
  35075. };
  35076. /**
  35077. * Bootstrap a hybrid AngularJS v1 / Angular v2 application.
  35078. *
  35079. * This `bootstrap` method is a direct replacement (takes same arguments) for AngularJS v1
  35080. * [`bootstrap`](https://docs.angularjs.org/api/ng/function/angular.bootstrap) method. Unlike
  35081. * AngularJS v1, this bootstrap is asynchronous.
  35082. *
  35083. * ### Example
  35084. *
  35085. * ```
  35086. * var adapter = new UpgradeAdapter();
  35087. * var module = angular.module('myExample', []);
  35088. * module.directive('ng2', adapter.downgradeNg2Component(Ng2));
  35089. *
  35090. * module.directive('ng1', function() {
  35091. * return {
  35092. * scope: { title: '=' },
  35093. * template: 'ng1[Hello {{title}}!](<span ng-transclude></span>)'
  35094. * };
  35095. * });
  35096. *
  35097. *
  35098. * @Component({
  35099. * selector: 'ng2',
  35100. * inputs: ['name'],
  35101. * template: 'ng2[<ng1 [title]="name">transclude</ng1>](<ng-content></ng-content>)',
  35102. * directives: [adapter.upgradeNg1Component('ng1')]
  35103. * })
  35104. * class Ng2 {
  35105. * }
  35106. *
  35107. * document.body.innerHTML = '<ng2 name="World">project</ng2>';
  35108. *
  35109. * adapter.bootstrap(document.body, ['myExample']).ready(function() {
  35110. * expect(document.body.textContent).toEqual(
  35111. * "ng2[ng1[Hello World!](transclude)](project)");
  35112. * });
  35113. * ```
  35114. */
  35115. UpgradeAdapter.prototype.bootstrap = function (element, modules, config) {
  35116. var _this = this;
  35117. var upgrade = new UpgradeAdapterRef();
  35118. var ng1Injector = null;
  35119. var platformRef = core_1.platform(browser_1.BROWSER_PROVIDERS);
  35120. var applicationRef = platformRef.application([
  35121. browser_1.BROWSER_APP_PROVIDERS,
  35122. core_1.provide(constants_1.NG1_INJECTOR, { useFactory: function () { return ng1Injector; } }),
  35123. core_1.provide(constants_1.NG1_COMPILE, { useFactory: function () { return ng1Injector.get(constants_1.NG1_COMPILE); } }),
  35124. this.providers
  35125. ]);
  35126. var injector = applicationRef.injector;
  35127. var ngZone = injector.get(core_1.NgZone);
  35128. var compiler = injector.get(core_1.Compiler);
  35129. var delayApplyExps = [];
  35130. var original$applyFn;
  35131. var rootScopePrototype;
  35132. var rootScope;
  35133. var protoViewRefMap = {};
  35134. var ng1Module = angular.module(this.idPrefix, modules);
  35135. var ng1compilePromise = null;
  35136. ng1Module.value(constants_1.NG2_INJECTOR, injector)
  35137. .value(constants_1.NG2_ZONE, ngZone)
  35138. .value(constants_1.NG2_COMPILER, compiler)
  35139. .value(constants_1.NG2_PROTO_VIEW_REF_MAP, protoViewRefMap)
  35140. .value(constants_1.NG2_APP_VIEW_MANAGER, injector.get(core_1.AppViewManager))
  35141. .config([
  35142. '$provide',
  35143. function (provide) {
  35144. provide.decorator(constants_1.NG1_ROOT_SCOPE, [
  35145. '$delegate',
  35146. function (rootScopeDelegate) {
  35147. rootScopePrototype = rootScopeDelegate.constructor.prototype;
  35148. if (rootScopePrototype.hasOwnProperty('$apply')) {
  35149. original$applyFn = rootScopePrototype.$apply;
  35150. rootScopePrototype.$apply = function (exp) { return delayApplyExps.push(exp); };
  35151. }
  35152. else {
  35153. throw new Error("Failed to find '$apply' on '$rootScope'!");
  35154. }
  35155. return rootScope = rootScopeDelegate;
  35156. }
  35157. ]);
  35158. }
  35159. ])
  35160. .run([
  35161. '$injector',
  35162. '$rootScope',
  35163. function (injector, rootScope) {
  35164. ng1Injector = injector;
  35165. async_1.ObservableWrapper.subscribe(ngZone.onTurnDone, function (_) { ngZone.run(function () { return rootScope.$apply(); }); });
  35166. ng1compilePromise =
  35167. upgrade_ng1_adapter_1.UpgradeNg1ComponentAdapterBuilder.resolve(_this.downgradedComponents, injector);
  35168. }
  35169. ]);
  35170. angular.element(element).data(util_1.controllerKey(constants_1.NG2_INJECTOR), injector);
  35171. ngZone.run(function () { angular.bootstrap(element, [_this.idPrefix], config); });
  35172. Promise.all([this.compileNg2Components(compiler, protoViewRefMap), ng1compilePromise])
  35173. .then(function () {
  35174. ngZone.run(function () {
  35175. if (rootScopePrototype) {
  35176. rootScopePrototype.$apply = original$applyFn; // restore original $apply
  35177. while (delayApplyExps.length) {
  35178. rootScope.$apply(delayApplyExps.shift());
  35179. }
  35180. upgrade._bootstrapDone(applicationRef, ng1Injector);
  35181. rootScopePrototype = null;
  35182. }
  35183. });
  35184. }, util_1.onError);
  35185. return upgrade;
  35186. };
  35187. /**
  35188. * Adds a provider to the top level environment of a hybrid AngularJS v1 / Angular v2 application.
  35189. *
  35190. * In hybrid AngularJS v1 / Angular v2 application, there is no one root Angular v2 component,
  35191. * for this reason we provide an application global way of registering providers which is
  35192. * consistent with single global injection in AngularJS v1.
  35193. *
  35194. * ### Example
  35195. *
  35196. * ```
  35197. * class Greeter {
  35198. * greet(name) {
  35199. * alert('Hello ' + name + '!');
  35200. * }
  35201. * }
  35202. *
  35203. * @Component({
  35204. * selector: 'app',
  35205. * template: ''
  35206. * })
  35207. * class App {
  35208. * constructor(greeter: Greeter) {
  35209. * this.greeter('World');
  35210. * }
  35211. * }
  35212. *
  35213. * var adapter = new UpgradeAdapter();
  35214. * adapter.addProvider(Greeter);
  35215. *
  35216. * var module = angular.module('myExample', []);
  35217. * module.directive('app', adapter.downgradeNg2Component(App));
  35218. *
  35219. * document.body.innerHTML = '<app></app>'
  35220. * adapter.bootstrap(document.body, ['myExample']);
  35221. *```
  35222. */
  35223. UpgradeAdapter.prototype.addProvider = function (provider) { this.providers.push(provider); };
  35224. /**
  35225. * Allows AngularJS v1 service to be accessible from Angular v2.
  35226. *
  35227. *
  35228. * ### Example
  35229. *
  35230. * ```
  35231. * class Login { ... }
  35232. * class Server { ... }
  35233. *
  35234. * @Injectable()
  35235. * class Example {
  35236. * constructor(@Inject('server') server, login: Login) {
  35237. * ...
  35238. * }
  35239. * }
  35240. *
  35241. * var module = angular.module('myExample', []);
  35242. * module.service('server', Server);
  35243. * module.service('login', Login);
  35244. *
  35245. * var adapter = new UpgradeAdapter();
  35246. * adapter.upgradeNg1Provider('server');
  35247. * adapter.upgradeNg1Provider('login', {asToken: Login});
  35248. * adapter.addProvider(Example);
  35249. *
  35250. * adapter.bootstrap(document.body, ['myExample']).ready((ref) => {
  35251. * var example: Example = ref.ng2Injector.get(Example);
  35252. * });
  35253. *
  35254. * ```
  35255. */
  35256. UpgradeAdapter.prototype.upgradeNg1Provider = function (name, options) {
  35257. var token = options && options.asToken || name;
  35258. this.providers.push(core_1.provide(token, {
  35259. useFactory: function (ng1Injector) { return ng1Injector.get(name); },
  35260. deps: [constants_1.NG1_INJECTOR]
  35261. }));
  35262. };
  35263. /**
  35264. * Allows Angular v2 service to be accessible from AngularJS v1.
  35265. *
  35266. *
  35267. * ### Example
  35268. *
  35269. * ```
  35270. * class Example {
  35271. * }
  35272. *
  35273. * var adapter = new UpgradeAdapter();
  35274. * adapter.addProvider(Example);
  35275. *
  35276. * var module = angular.module('myExample', []);
  35277. * module.factory('example', adapter.downgradeNg2Provider(Example));
  35278. *
  35279. * adapter.bootstrap(document.body, ['myExample']).ready((ref) => {
  35280. * var example: Example = ref.ng1Injector.get('example');
  35281. * });
  35282. *
  35283. * ```
  35284. */
  35285. UpgradeAdapter.prototype.downgradeNg2Provider = function (token) {
  35286. var factory = function (injector) { return injector.get(token); };
  35287. factory.$inject = [constants_1.NG2_INJECTOR];
  35288. return factory;
  35289. };
  35290. /* @internal */
  35291. UpgradeAdapter.prototype.compileNg2Components = function (compiler, protoViewRefMap) {
  35292. var _this = this;
  35293. var promises = [];
  35294. var types = this.upgradedComponents;
  35295. for (var i = 0; i < types.length; i++) {
  35296. promises.push(compiler.compileInHost(types[i]));
  35297. }
  35298. return Promise.all(promises).then(function (protoViews) {
  35299. var types = _this.upgradedComponents;
  35300. for (var i = 0; i < protoViews.length; i++) {
  35301. protoViewRefMap[metadata_1.getComponentInfo(types[i]).selector] = protoViews[i];
  35302. }
  35303. return protoViewRefMap;
  35304. }, util_1.onError);
  35305. };
  35306. return UpgradeAdapter;
  35307. })();
  35308. exports.UpgradeAdapter = UpgradeAdapter;
  35309. function ng1ComponentDirective(info, idPrefix) {
  35310. directiveFactory.$inject = [constants_1.NG2_PROTO_VIEW_REF_MAP, constants_1.NG2_APP_VIEW_MANAGER, constants_1.NG1_PARSE];
  35311. function directiveFactory(protoViewRefMap, viewManager, parse) {
  35312. var protoView = protoViewRefMap[info.selector];
  35313. if (!protoView)
  35314. throw new Error('Expecting ProtoViewRef for: ' + info.selector);
  35315. var idCount = 0;
  35316. return {
  35317. restrict: 'E',
  35318. require: constants_1.REQUIRE_INJECTOR,
  35319. link: {
  35320. post: function (scope, element, attrs, parentInjector, transclude) {
  35321. var domElement = element[0];
  35322. var facade = new downgrade_ng2_adapter_1.DowngradeNg2ComponentAdapter(idPrefix + (idCount++), info, element, attrs, scope, parentInjector, parse, viewManager, protoView);
  35323. facade.setupInputs();
  35324. facade.bootstrapNg2();
  35325. facade.projectContent();
  35326. facade.setupOutputs();
  35327. facade.registerCleanup();
  35328. }
  35329. }
  35330. };
  35331. }
  35332. return directiveFactory;
  35333. }
  35334. /**
  35335. * Use `UgradeAdapterRef` to control a hybrid AngularJS v1 / Angular v2 application.
  35336. */
  35337. var UpgradeAdapterRef = (function () {
  35338. function UpgradeAdapterRef() {
  35339. /* @internal */
  35340. this._readyFn = null;
  35341. this.ng1RootScope = null;
  35342. this.ng1Injector = null;
  35343. this.ng2ApplicationRef = null;
  35344. this.ng2Injector = null;
  35345. }
  35346. /* @internal */
  35347. UpgradeAdapterRef.prototype._bootstrapDone = function (applicationRef, ng1Injector) {
  35348. this.ng2ApplicationRef = applicationRef;
  35349. this.ng2Injector = applicationRef.injector;
  35350. this.ng1Injector = ng1Injector;
  35351. this.ng1RootScope = ng1Injector.get(constants_1.NG1_ROOT_SCOPE);
  35352. this._readyFn && this._readyFn(this);
  35353. };
  35354. /**
  35355. * Register a callback function which is notified upon successful hybrid AngularJS v1 / Angular v2
  35356. * application has been bootstrapped.
  35357. *
  35358. * The `ready` callback function is invoked inside the Angular v2 zone, therefore it does not
  35359. * require a call to `$apply()`.
  35360. */
  35361. UpgradeAdapterRef.prototype.ready = function (fn) { this._readyFn = fn; };
  35362. /**
  35363. * Dispose of running hybrid AngularJS v1 / Angular v2 application.
  35364. */
  35365. UpgradeAdapterRef.prototype.dispose = function () {
  35366. this.ng1Injector.get(constants_1.NG1_ROOT_SCOPE).$destroy();
  35367. this.ng2ApplicationRef.dispose();
  35368. };
  35369. return UpgradeAdapterRef;
  35370. })();
  35371. exports.UpgradeAdapterRef = UpgradeAdapterRef;
  35372. /***/ },
  35373. /* 253 */
  35374. /***/ function(module, exports, __webpack_require__) {
  35375. var core_1 = __webpack_require__(2);
  35376. var COMPONENT_SELECTOR = /^[\w|-]*$/;
  35377. var SKEWER_CASE = /-(\w)/g;
  35378. var directiveResolver = new core_1.DirectiveResolver();
  35379. function getComponentInfo(type) {
  35380. var resolvedMetadata = directiveResolver.resolve(type);
  35381. var selector = resolvedMetadata.selector;
  35382. if (!selector.match(COMPONENT_SELECTOR)) {
  35383. throw new Error('Only selectors matching element names are supported, got: ' + selector);
  35384. }
  35385. var selector = selector.replace(SKEWER_CASE, function (all, letter) { return letter.toUpperCase(); });
  35386. return {
  35387. type: type,
  35388. selector: selector,
  35389. inputs: parseFields(resolvedMetadata.inputs),
  35390. outputs: parseFields(resolvedMetadata.outputs)
  35391. };
  35392. }
  35393. exports.getComponentInfo = getComponentInfo;
  35394. function parseFields(names) {
  35395. var attrProps = [];
  35396. if (names) {
  35397. for (var i = 0; i < names.length; i++) {
  35398. var parts = names[i].split(':');
  35399. var prop = parts[0].trim();
  35400. var attr = (parts[1] || parts[0]).trim();
  35401. var capitalAttr = attr.charAt(0).toUpperCase() + attr.substr(1);
  35402. attrProps.push({
  35403. prop: prop,
  35404. attr: attr,
  35405. bracketAttr: "[" + attr + "]",
  35406. parenAttr: "(" + attr + ")",
  35407. bracketParenAttr: "[(" + attr + ")]",
  35408. onAttr: "on" + capitalAttr,
  35409. bindAttr: "bind" + capitalAttr,
  35410. bindonAttr: "bindon" + capitalAttr
  35411. });
  35412. }
  35413. }
  35414. return attrProps;
  35415. }
  35416. exports.parseFields = parseFields;
  35417. /***/ },
  35418. /* 254 */
  35419. /***/ function(module, exports) {
  35420. function stringify(obj) {
  35421. if (typeof obj == 'function')
  35422. return obj.name || obj.toString();
  35423. return '' + obj;
  35424. }
  35425. exports.stringify = stringify;
  35426. function onError(e) {
  35427. // TODO: (misko): We seem to not have a stack trace here!
  35428. console.log(e, e.stack);
  35429. throw e;
  35430. }
  35431. exports.onError = onError;
  35432. function controllerKey(name) {
  35433. return '$' + name + 'Controller';
  35434. }
  35435. exports.controllerKey = controllerKey;
  35436. /***/ },
  35437. /* 255 */
  35438. /***/ function(module, exports) {
  35439. exports.NG2_APP_VIEW_MANAGER = 'ng2.AppViewManager';
  35440. exports.NG2_COMPILER = 'ng2.Compiler';
  35441. exports.NG2_INJECTOR = 'ng2.Injector';
  35442. exports.NG2_PROTO_VIEW_REF_MAP = 'ng2.ProtoViewRefMap';
  35443. exports.NG2_ZONE = 'ng2.NgZone';
  35444. exports.NG1_CONTROLLER = '$controller';
  35445. exports.NG1_SCOPE = '$scope';
  35446. exports.NG1_ROOT_SCOPE = '$rootScope';
  35447. exports.NG1_COMPILE = '$compile';
  35448. exports.NG1_HTTP_BACKEND = '$httpBackend';
  35449. exports.NG1_INJECTOR = '$injector';
  35450. exports.NG1_PARSE = '$parse';
  35451. exports.NG1_TEMPLATE_CACHE = '$templateCache';
  35452. exports.REQUIRE_INJECTOR = '^' + exports.NG2_INJECTOR;
  35453. /***/ },
  35454. /* 256 */
  35455. /***/ function(module, exports, __webpack_require__) {
  35456. var core_1 = __webpack_require__(2);
  35457. var constants_1 = __webpack_require__(255);
  35458. var INITIAL_VALUE = {
  35459. __UNINITIALIZED__: true
  35460. };
  35461. var DowngradeNg2ComponentAdapter = (function () {
  35462. function DowngradeNg2ComponentAdapter(id, info, element, attrs, scope, parentInjector, parse, viewManager, protoView) {
  35463. this.id = id;
  35464. this.info = info;
  35465. this.element = element;
  35466. this.attrs = attrs;
  35467. this.scope = scope;
  35468. this.parentInjector = parentInjector;
  35469. this.parse = parse;
  35470. this.viewManager = viewManager;
  35471. this.protoView = protoView;
  35472. this.component = null;
  35473. this.inputChangeCount = 0;
  35474. this.inputChanges = null;
  35475. this.hostViewRef = null;
  35476. this.changeDetector = null;
  35477. this.contentInserctionPoint = null;
  35478. this.element[0].id = id;
  35479. this.componentScope = scope.$new();
  35480. this.childNodes = element.contents();
  35481. }
  35482. DowngradeNg2ComponentAdapter.prototype.bootstrapNg2 = function () {
  35483. var childInjector = this.parentInjector.resolveAndCreateChild([core_1.provide(constants_1.NG1_SCOPE, { useValue: this.componentScope })]);
  35484. this.hostViewRef =
  35485. this.viewManager.createRootHostView(this.protoView, '#' + this.id, childInjector);
  35486. var renderer = this.hostViewRef.render;
  35487. var hostElement = this.viewManager.getHostElement(this.hostViewRef);
  35488. this.changeDetector = this.hostViewRef.changeDetectorRef;
  35489. this.component = this.viewManager.getComponent(hostElement);
  35490. this.contentInserctionPoint = renderer.rootContentInsertionPoints[0];
  35491. };
  35492. DowngradeNg2ComponentAdapter.prototype.setupInputs = function () {
  35493. var _this = this;
  35494. var attrs = this.attrs;
  35495. var inputs = this.info.inputs;
  35496. for (var i = 0; i < inputs.length; i++) {
  35497. var input = inputs[i];
  35498. var expr = null;
  35499. if (attrs.hasOwnProperty(input.attr)) {
  35500. var observeFn = (function (prop) {
  35501. var prevValue = INITIAL_VALUE;
  35502. return function (value) {
  35503. if (_this.inputChanges !== null) {
  35504. _this.inputChangeCount++;
  35505. _this.inputChanges[prop] =
  35506. new Ng1Change(value, prevValue === INITIAL_VALUE ? value : prevValue);
  35507. prevValue = value;
  35508. }
  35509. _this.component[prop] = value;
  35510. };
  35511. })(input.prop);
  35512. attrs.$observe(input.attr, observeFn);
  35513. }
  35514. else if (attrs.hasOwnProperty(input.bindAttr)) {
  35515. expr = attrs[input.bindAttr];
  35516. }
  35517. else if (attrs.hasOwnProperty(input.bracketAttr)) {
  35518. expr = attrs[input.bracketAttr];
  35519. }
  35520. else if (attrs.hasOwnProperty(input.bindonAttr)) {
  35521. expr = attrs[input.bindonAttr];
  35522. }
  35523. else if (attrs.hasOwnProperty(input.bracketParenAttr)) {
  35524. expr = attrs[input.bracketParenAttr];
  35525. }
  35526. if (expr != null) {
  35527. var watchFn = (function (prop) { return function (value, prevValue) {
  35528. if (_this.inputChanges != null) {
  35529. _this.inputChangeCount++;
  35530. _this.inputChanges[prop] = new Ng1Change(prevValue, value);
  35531. }
  35532. _this.component[prop] = value;
  35533. }; })(input.prop);
  35534. this.componentScope.$watch(expr, watchFn);
  35535. }
  35536. }
  35537. var prototype = this.info.type.prototype;
  35538. if (prototype && prototype.ngOnChanges) {
  35539. // Detect: OnChanges interface
  35540. this.inputChanges = {};
  35541. this.componentScope.$watch(function () { return _this.inputChangeCount; }, function () {
  35542. var inputChanges = _this.inputChanges;
  35543. _this.inputChanges = {};
  35544. _this.component.ngOnChanges(inputChanges);
  35545. });
  35546. }
  35547. this.componentScope.$watch(function () { return _this.changeDetector && _this.changeDetector.detectChanges(); });
  35548. };
  35549. DowngradeNg2ComponentAdapter.prototype.projectContent = function () {
  35550. var childNodes = this.childNodes;
  35551. if (this.contentInserctionPoint) {
  35552. var parent = this.contentInserctionPoint.parentNode;
  35553. for (var i = 0, ii = childNodes.length; i < ii; i++) {
  35554. parent.insertBefore(childNodes[i], this.contentInserctionPoint);
  35555. }
  35556. }
  35557. };
  35558. DowngradeNg2ComponentAdapter.prototype.setupOutputs = function () {
  35559. var _this = this;
  35560. var attrs = this.attrs;
  35561. var outputs = this.info.outputs;
  35562. for (var j = 0; j < outputs.length; j++) {
  35563. var output = outputs[j];
  35564. var expr = null;
  35565. var assignExpr = false;
  35566. var bindonAttr = output.bindonAttr ? output.bindonAttr.substring(0, output.bindonAttr.length - 6) : null;
  35567. var bracketParenAttr = output.bracketParenAttr ?
  35568. "[(" + output.bracketParenAttr.substring(2, output.bracketParenAttr.length - 8) + ")]" :
  35569. null;
  35570. if (attrs.hasOwnProperty(output.onAttr)) {
  35571. expr = attrs[output.onAttr];
  35572. }
  35573. else if (attrs.hasOwnProperty(output.parenAttr)) {
  35574. expr = attrs[output.parenAttr];
  35575. }
  35576. else if (attrs.hasOwnProperty(bindonAttr)) {
  35577. expr = attrs[bindonAttr];
  35578. assignExpr = true;
  35579. }
  35580. else if (attrs.hasOwnProperty(bracketParenAttr)) {
  35581. expr = attrs[bracketParenAttr];
  35582. assignExpr = true;
  35583. }
  35584. if (expr != null && assignExpr != null) {
  35585. var getter = this.parse(expr);
  35586. var setter = getter.assign;
  35587. if (assignExpr && !setter) {
  35588. throw new Error("Expression '" + expr + "' is not assignable!");
  35589. }
  35590. var emitter = this.component[output.prop];
  35591. if (emitter) {
  35592. emitter.subscribe({
  35593. next: assignExpr ? (function (setter) { return function (value) { return setter(_this.scope, value); }; })(setter) :
  35594. (function (getter) { return function (value) { return getter(_this.scope, { $event: value }); }; })(getter)
  35595. });
  35596. }
  35597. else {
  35598. throw new Error("Missing emitter '" + output.prop + "' on component '" + this.info.selector + "'!");
  35599. }
  35600. }
  35601. }
  35602. };
  35603. DowngradeNg2ComponentAdapter.prototype.registerCleanup = function () {
  35604. var _this = this;
  35605. this.element.bind('$remove', function () { return _this.viewManager.destroyRootHostView(_this.hostViewRef); });
  35606. };
  35607. return DowngradeNg2ComponentAdapter;
  35608. })();
  35609. exports.DowngradeNg2ComponentAdapter = DowngradeNg2ComponentAdapter;
  35610. var Ng1Change = (function () {
  35611. function Ng1Change(previousValue, currentValue) {
  35612. this.previousValue = previousValue;
  35613. this.currentValue = currentValue;
  35614. }
  35615. Ng1Change.prototype.isFirstChange = function () { return this.previousValue === this.currentValue; };
  35616. return Ng1Change;
  35617. })();
  35618. /***/ },
  35619. /* 257 */
  35620. /***/ function(module, exports, __webpack_require__) {
  35621. var core_1 = __webpack_require__(2);
  35622. var constants_1 = __webpack_require__(255);
  35623. var util_1 = __webpack_require__(254);
  35624. var angular = __webpack_require__(258);
  35625. var CAMEL_CASE = /([A-Z])/g;
  35626. var INITIAL_VALUE = {
  35627. __UNINITIALIZED__: true
  35628. };
  35629. var NOT_SUPPORTED = 'NOT_SUPPORTED';
  35630. var UpgradeNg1ComponentAdapterBuilder = (function () {
  35631. function UpgradeNg1ComponentAdapterBuilder(name) {
  35632. this.name = name;
  35633. this.inputs = [];
  35634. this.inputsRename = [];
  35635. this.outputs = [];
  35636. this.outputsRename = [];
  35637. this.propertyOutputs = [];
  35638. this.checkProperties = [];
  35639. this.propertyMap = {};
  35640. this.linkFn = null;
  35641. this.directive = null;
  35642. this.$controller = null;
  35643. var selector = name.replace(CAMEL_CASE, function (all, next) { return '-' + next.toLowerCase(); });
  35644. var self = this;
  35645. this.type =
  35646. core_1.Directive({ selector: selector, inputs: this.inputsRename, outputs: this.outputsRename })
  35647. .Class({
  35648. constructor: [
  35649. new core_1.Inject(constants_1.NG1_SCOPE),
  35650. core_1.ElementRef,
  35651. function (scope, elementRef) {
  35652. return new UpgradeNg1ComponentAdapter(self.linkFn, scope, self.directive, elementRef, self.$controller, self.inputs, self.outputs, self.propertyOutputs, self.checkProperties, self.propertyMap);
  35653. }
  35654. ],
  35655. ngOnChanges: function () { },
  35656. ngDoCheck: function () { }
  35657. });
  35658. }
  35659. UpgradeNg1ComponentAdapterBuilder.prototype.extractDirective = function (injector) {
  35660. var directives = injector.get(this.name + 'Directive');
  35661. if (directives.length > 1) {
  35662. throw new Error('Only support single directive definition for: ' + this.name);
  35663. }
  35664. var directive = directives[0];
  35665. if (directive.replace)
  35666. this.notSupported('replace');
  35667. if (directive.terminal)
  35668. this.notSupported('terminal');
  35669. var link = directive.link;
  35670. if (typeof link == 'object') {
  35671. if (link.post)
  35672. this.notSupported('link.post');
  35673. }
  35674. return directive;
  35675. };
  35676. UpgradeNg1ComponentAdapterBuilder.prototype.notSupported = function (feature) {
  35677. throw new Error("Upgraded directive '" + this.name + "' does not support '" + feature + "'.");
  35678. };
  35679. UpgradeNg1ComponentAdapterBuilder.prototype.extractBindings = function () {
  35680. var scope = this.directive.scope;
  35681. if (typeof scope == 'object') {
  35682. for (var name in scope) {
  35683. if (scope.hasOwnProperty(name)) {
  35684. var localName = scope[name];
  35685. var type = localName.charAt(0);
  35686. localName = localName.substr(1) || name;
  35687. var outputName = 'output_' + name;
  35688. var outputNameRename = outputName + ': ' + name;
  35689. var outputNameRenameChange = outputName + ': ' + name + 'Change';
  35690. var inputName = 'input_' + name;
  35691. var inputNameRename = inputName + ': ' + name;
  35692. switch (type) {
  35693. case '=':
  35694. this.propertyOutputs.push(outputName);
  35695. this.checkProperties.push(localName);
  35696. this.outputs.push(outputName);
  35697. this.outputsRename.push(outputNameRenameChange);
  35698. this.propertyMap[outputName] = localName;
  35699. // don't break; let it fall through to '@'
  35700. case '@':
  35701. this.inputs.push(inputName);
  35702. this.inputsRename.push(inputNameRename);
  35703. this.propertyMap[inputName] = localName;
  35704. break;
  35705. case '&':
  35706. this.outputs.push(outputName);
  35707. this.outputsRename.push(outputNameRename);
  35708. this.propertyMap[outputName] = localName;
  35709. break;
  35710. default:
  35711. var json = JSON.stringify(scope);
  35712. throw new Error("Unexpected mapping '" + type + "' in '" + json + "' in '" + this.name + "' directive.");
  35713. }
  35714. }
  35715. }
  35716. }
  35717. };
  35718. UpgradeNg1ComponentAdapterBuilder.prototype.compileTemplate = function (compile, templateCache, httpBackend) {
  35719. var _this = this;
  35720. if (this.directive.template !== undefined) {
  35721. this.linkFn = compileHtml(this.directive.template);
  35722. }
  35723. else if (this.directive.templateUrl) {
  35724. var url = this.directive.templateUrl;
  35725. var html = templateCache.get(url);
  35726. if (html !== undefined) {
  35727. this.linkFn = compileHtml(html);
  35728. }
  35729. else {
  35730. return new Promise(function (resolve, err) {
  35731. httpBackend('GET', url, null, function (status, response) {
  35732. if (status == 200) {
  35733. resolve(_this.linkFn = compileHtml(templateCache.put(url, response)));
  35734. }
  35735. else {
  35736. err("GET " + url + " returned " + status + ": " + response);
  35737. }
  35738. });
  35739. });
  35740. }
  35741. }
  35742. else {
  35743. throw new Error("Directive '" + this.name + "' is not a component, it is missing template.");
  35744. }
  35745. return null;
  35746. function compileHtml(html) {
  35747. var div = document.createElement('div');
  35748. div.innerHTML = html;
  35749. return compile(div.childNodes);
  35750. }
  35751. };
  35752. UpgradeNg1ComponentAdapterBuilder.resolve = function (exportedComponents, injector) {
  35753. var promises = [];
  35754. var compile = injector.get(constants_1.NG1_COMPILE);
  35755. var templateCache = injector.get(constants_1.NG1_TEMPLATE_CACHE);
  35756. var httpBackend = injector.get(constants_1.NG1_HTTP_BACKEND);
  35757. var $controller = injector.get(constants_1.NG1_CONTROLLER);
  35758. for (var name in exportedComponents) {
  35759. if (exportedComponents.hasOwnProperty(name)) {
  35760. var exportedComponent = exportedComponents[name];
  35761. exportedComponent.directive = exportedComponent.extractDirective(injector);
  35762. exportedComponent.$controller = $controller;
  35763. exportedComponent.extractBindings();
  35764. var promise = exportedComponent.compileTemplate(compile, templateCache, httpBackend);
  35765. if (promise)
  35766. promises.push(promise);
  35767. }
  35768. }
  35769. return Promise.all(promises);
  35770. };
  35771. return UpgradeNg1ComponentAdapterBuilder;
  35772. })();
  35773. exports.UpgradeNg1ComponentAdapterBuilder = UpgradeNg1ComponentAdapterBuilder;
  35774. var UpgradeNg1ComponentAdapter = (function () {
  35775. function UpgradeNg1ComponentAdapter(linkFn, scope, directive, elementRef, $controller, inputs, outputs, propOuts, checkProperties, propertyMap) {
  35776. this.directive = directive;
  35777. this.inputs = inputs;
  35778. this.outputs = outputs;
  35779. this.propOuts = propOuts;
  35780. this.checkProperties = checkProperties;
  35781. this.propertyMap = propertyMap;
  35782. this.destinationObj = null;
  35783. this.checkLastValues = [];
  35784. var element = elementRef.nativeElement;
  35785. var childNodes = [];
  35786. var childNode;
  35787. while (childNode = element.firstChild) {
  35788. element.removeChild(childNode);
  35789. childNodes.push(childNode);
  35790. }
  35791. var componentScope = scope.$new(!!directive.scope);
  35792. var $element = angular.element(element);
  35793. var controllerType = directive.controller;
  35794. var controller = null;
  35795. if (controllerType) {
  35796. var locals = { $scope: componentScope, $element: $element };
  35797. controller = $controller(controllerType, locals, null, directive.controllerAs);
  35798. $element.data(util_1.controllerKey(directive.name), controller);
  35799. }
  35800. var link = directive.link;
  35801. if (typeof link == 'object')
  35802. link = link.pre;
  35803. if (link) {
  35804. var attrs = NOT_SUPPORTED;
  35805. var transcludeFn = NOT_SUPPORTED;
  35806. var linkController = this.resolveRequired($element, directive.require);
  35807. directive.link(componentScope, $element, attrs, linkController, transcludeFn);
  35808. }
  35809. this.destinationObj = directive.bindToController && controller ? controller : componentScope;
  35810. linkFn(componentScope, function (clonedElement, scope) {
  35811. for (var i = 0, ii = clonedElement.length; i < ii; i++) {
  35812. element.appendChild(clonedElement[i]);
  35813. }
  35814. }, { parentBoundTranscludeFn: function (scope, cloneAttach) { cloneAttach(childNodes); } });
  35815. for (var i = 0; i < inputs.length; i++) {
  35816. this[inputs[i]] = null;
  35817. }
  35818. for (var j = 0; j < outputs.length; j++) {
  35819. var emitter = this[outputs[j]] = new core_1.EventEmitter();
  35820. this.setComponentProperty(outputs[j], (function (emitter) { return function (value) { return emitter.emit(value); }; })(emitter));
  35821. }
  35822. for (var k = 0; k < propOuts.length; k++) {
  35823. this[propOuts[k]] = new core_1.EventEmitter();
  35824. this.checkLastValues.push(INITIAL_VALUE);
  35825. }
  35826. }
  35827. UpgradeNg1ComponentAdapter.prototype.ngOnChanges = function (changes) {
  35828. for (var name in changes) {
  35829. if (changes.hasOwnProperty(name)) {
  35830. var change = changes[name];
  35831. this.setComponentProperty(name, change.currentValue);
  35832. }
  35833. }
  35834. };
  35835. UpgradeNg1ComponentAdapter.prototype.ngDoCheck = function () {
  35836. var count = 0;
  35837. var destinationObj = this.destinationObj;
  35838. var lastValues = this.checkLastValues;
  35839. var checkProperties = this.checkProperties;
  35840. for (var i = 0; i < checkProperties.length; i++) {
  35841. var value = destinationObj[checkProperties[i]];
  35842. var last = lastValues[i];
  35843. if (value !== last) {
  35844. if (typeof value == 'number' && isNaN(value) && typeof last == 'number' && isNaN(last)) {
  35845. }
  35846. else {
  35847. var eventEmitter = this[this.propOuts[i]];
  35848. eventEmitter.emit(lastValues[i] = value);
  35849. }
  35850. }
  35851. }
  35852. return count;
  35853. };
  35854. UpgradeNg1ComponentAdapter.prototype.setComponentProperty = function (name, value) {
  35855. this.destinationObj[this.propertyMap[name]] = value;
  35856. };
  35857. UpgradeNg1ComponentAdapter.prototype.resolveRequired = function ($element, require) {
  35858. if (!require) {
  35859. return undefined;
  35860. }
  35861. else if (typeof require == 'string') {
  35862. var name = require;
  35863. var isOptional = false;
  35864. var startParent = false;
  35865. var searchParents = false;
  35866. var ch;
  35867. if (name.charAt(0) == '?') {
  35868. isOptional = true;
  35869. name = name.substr(1);
  35870. }
  35871. if (name.charAt(0) == '^') {
  35872. searchParents = true;
  35873. name = name.substr(1);
  35874. }
  35875. if (name.charAt(0) == '^') {
  35876. startParent = true;
  35877. name = name.substr(1);
  35878. }
  35879. var key = util_1.controllerKey(name);
  35880. if (startParent)
  35881. $element = $element.parent();
  35882. var dep = searchParents ? $element.inheritedData(key) : $element.data(key);
  35883. if (!dep && !isOptional) {
  35884. throw new Error("Can not locate '" + require + "' in '" + this.directive.name + "'.");
  35885. }
  35886. return dep;
  35887. }
  35888. else if (require instanceof Array) {
  35889. var deps = [];
  35890. for (var i = 0; i < require.length; i++) {
  35891. deps.push(this.resolveRequired($element, require[i]));
  35892. }
  35893. return deps;
  35894. }
  35895. throw new Error("Directive '" + this.directive.name + "' require syntax unrecognized: " + this.directive.require);
  35896. };
  35897. return UpgradeNg1ComponentAdapter;
  35898. })();
  35899. /***/ },
  35900. /* 258 */
  35901. /***/ function(module, exports) {
  35902. function noNg() {
  35903. throw new Error('AngularJS v1.x is not loaded!');
  35904. }
  35905. var angular = { bootstrap: noNg, module: noNg, element: noNg, version: noNg };
  35906. try {
  35907. if (window.hasOwnProperty('angular')) {
  35908. angular = window.angular;
  35909. }
  35910. }
  35911. catch (e) {
  35912. }
  35913. exports.bootstrap = angular.bootstrap;
  35914. exports.module = angular.module;
  35915. exports.element = angular.element;
  35916. exports.version = angular.version;
  35917. /***/ }
  35918. /******/ ])
  35919. });
  35920. ;