Front end of the Slack clone application.

platform-browser.umd.js 164KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445
  1. /**
  2. * @license Angular v5.2.11
  3. * (c) 2010-2018 Google, Inc. https://angular.io/
  4. * License: MIT
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core')) :
  8. typeof define === 'function' && define.amd ? define('@angular/platform-browser', ['exports', '@angular/common', '@angular/core'], factory) :
  9. (factory((global.ng = global.ng || {}, global.ng.platformBrowser = {}),global.ng.common,global.ng.core));
  10. }(this, (function (exports,_angular_common,_angular_core) { 'use strict';
  11. /*! *****************************************************************************
  12. Copyright (c) Microsoft Corporation. All rights reserved.
  13. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  14. this file except in compliance with the License. You may obtain a copy of the
  15. License at http://www.apache.org/licenses/LICENSE-2.0
  16. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  18. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  19. MERCHANTABLITY OR NON-INFRINGEMENT.
  20. See the Apache Version 2.0 License for specific language governing permissions
  21. and limitations under the License.
  22. ***************************************************************************** */
  23. /* global Reflect, Promise */
  24. var extendStatics = Object.setPrototypeOf ||
  25. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  27. function __extends(d, b) {
  28. extendStatics(d, b);
  29. function __() { this.constructor = d; }
  30. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31. }
  32. var __assign = Object.assign || function __assign(t) {
  33. for (var s, i = 1, n = arguments.length; i < n; i++) {
  34. s = arguments[i];
  35. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  36. }
  37. return t;
  38. };
  39. /**
  40. * @license Angular v5.2.11
  41. * (c) 2010-2018 Google, Inc. https://angular.io/
  42. * License: MIT
  43. */
  44. /**
  45. * @fileoverview added by tsickle
  46. * @suppress {checkTypes} checked by tsc
  47. */
  48. /**
  49. * @license
  50. * Copyright Google Inc. All Rights Reserved.
  51. *
  52. * Use of this source code is governed by an MIT-style license that can be
  53. * found in the LICENSE file at https://angular.io/license
  54. */
  55. var _DOM = /** @type {?} */ ((null));
  56. /**
  57. * @return {?}
  58. */
  59. function getDOM() {
  60. return _DOM;
  61. }
  62. /**
  63. * @param {?} adapter
  64. * @return {?}
  65. */
  66. /**
  67. * @param {?} adapter
  68. * @return {?}
  69. */
  70. function setRootDomAdapter(adapter) {
  71. if (!_DOM) {
  72. _DOM = adapter;
  73. }
  74. }
  75. /**
  76. * Provides DOM operations in an environment-agnostic way.
  77. *
  78. * \@security Tread carefully! Interacting with the DOM directly is dangerous and
  79. * can introduce XSS risks.
  80. * @abstract
  81. */
  82. var DomAdapter = /** @class */ (function () {
  83. function DomAdapter() {
  84. this.resourceLoaderType = /** @type {?} */ ((null));
  85. }
  86. Object.defineProperty(DomAdapter.prototype, "attrToPropMap", {
  87. /**
  88. * Maps attribute names to their corresponding property names for cases
  89. * where attribute name doesn't match property name.
  90. */
  91. get: /**
  92. * Maps attribute names to their corresponding property names for cases
  93. * where attribute name doesn't match property name.
  94. * @return {?}
  95. */
  96. function () { return this._attrToPropMap; },
  97. set: /**
  98. * @param {?} value
  99. * @return {?}
  100. */
  101. function (value) { this._attrToPropMap = value; },
  102. enumerable: true,
  103. configurable: true
  104. });
  105. return DomAdapter;
  106. }());
  107. /**
  108. * @fileoverview added by tsickle
  109. * @suppress {checkTypes} checked by tsc
  110. */
  111. /**
  112. * @license
  113. * Copyright Google Inc. All Rights Reserved.
  114. *
  115. * Use of this source code is governed by an MIT-style license that can be
  116. * found in the LICENSE file at https://angular.io/license
  117. */
  118. /**
  119. * Provides DOM operations in any browser environment.
  120. *
  121. * \@security Tread carefully! Interacting with the DOM directly is dangerous and
  122. * can introduce XSS risks.
  123. * @abstract
  124. */
  125. var GenericBrowserDomAdapter = /** @class */ (function (_super) {
  126. __extends(GenericBrowserDomAdapter, _super);
  127. function GenericBrowserDomAdapter() {
  128. var _this = _super.call(this) || this;
  129. _this._animationPrefix = null;
  130. _this._transitionEnd = null;
  131. try {
  132. var /** @type {?} */ element_1 = _this.createElement('div', document);
  133. if (_this.getStyle(element_1, 'animationName') != null) {
  134. _this._animationPrefix = '';
  135. }
  136. else {
  137. var /** @type {?} */ domPrefixes = ['Webkit', 'Moz', 'O', 'ms'];
  138. for (var /** @type {?} */ i = 0; i < domPrefixes.length; i++) {
  139. if (_this.getStyle(element_1, domPrefixes[i] + 'AnimationName') != null) {
  140. _this._animationPrefix = '-' + domPrefixes[i].toLowerCase() + '-';
  141. break;
  142. }
  143. }
  144. }
  145. var /** @type {?} */ transEndEventNames_1 = {
  146. WebkitTransition: 'webkitTransitionEnd',
  147. MozTransition: 'transitionend',
  148. OTransition: 'oTransitionEnd otransitionend',
  149. transition: 'transitionend'
  150. };
  151. Object.keys(transEndEventNames_1).forEach(function (key) {
  152. if (_this.getStyle(element_1, key) != null) {
  153. _this._transitionEnd = transEndEventNames_1[key];
  154. }
  155. });
  156. }
  157. catch (/** @type {?} */ e) {
  158. _this._animationPrefix = null;
  159. _this._transitionEnd = null;
  160. }
  161. return _this;
  162. }
  163. /**
  164. * @param {?} el
  165. * @return {?}
  166. */
  167. GenericBrowserDomAdapter.prototype.getDistributedNodes = /**
  168. * @param {?} el
  169. * @return {?}
  170. */
  171. function (el) { return (/** @type {?} */ (el)).getDistributedNodes(); };
  172. /**
  173. * @param {?} el
  174. * @param {?} baseUrl
  175. * @param {?} href
  176. * @return {?}
  177. */
  178. GenericBrowserDomAdapter.prototype.resolveAndSetHref = /**
  179. * @param {?} el
  180. * @param {?} baseUrl
  181. * @param {?} href
  182. * @return {?}
  183. */
  184. function (el, baseUrl, href) {
  185. el.href = href == null ? baseUrl : baseUrl + '/../' + href;
  186. };
  187. /**
  188. * @return {?}
  189. */
  190. GenericBrowserDomAdapter.prototype.supportsDOMEvents = /**
  191. * @return {?}
  192. */
  193. function () { return true; };
  194. /**
  195. * @return {?}
  196. */
  197. GenericBrowserDomAdapter.prototype.supportsNativeShadowDOM = /**
  198. * @return {?}
  199. */
  200. function () {
  201. return typeof (/** @type {?} */ (document.body)).createShadowRoot === 'function';
  202. };
  203. /**
  204. * @return {?}
  205. */
  206. GenericBrowserDomAdapter.prototype.getAnimationPrefix = /**
  207. * @return {?}
  208. */
  209. function () { return this._animationPrefix ? this._animationPrefix : ''; };
  210. /**
  211. * @return {?}
  212. */
  213. GenericBrowserDomAdapter.prototype.getTransitionEnd = /**
  214. * @return {?}
  215. */
  216. function () { return this._transitionEnd ? this._transitionEnd : ''; };
  217. /**
  218. * @return {?}
  219. */
  220. GenericBrowserDomAdapter.prototype.supportsAnimation = /**
  221. * @return {?}
  222. */
  223. function () {
  224. return this._animationPrefix != null && this._transitionEnd != null;
  225. };
  226. return GenericBrowserDomAdapter;
  227. }(DomAdapter));
  228. /**
  229. * @fileoverview added by tsickle
  230. * @suppress {checkTypes} checked by tsc
  231. */
  232. /**
  233. * @license
  234. * Copyright Google Inc. All Rights Reserved.
  235. *
  236. * Use of this source code is governed by an MIT-style license that can be
  237. * found in the LICENSE file at https://angular.io/license
  238. */
  239. var _attrToPropMap = {
  240. 'class': 'className',
  241. 'innerHtml': 'innerHTML',
  242. 'readonly': 'readOnly',
  243. 'tabindex': 'tabIndex',
  244. };
  245. var DOM_KEY_LOCATION_NUMPAD = 3;
  246. // Map to convert some key or keyIdentifier values to what will be returned by getEventKey
  247. var _keyMap = {
  248. // The following values are here for cross-browser compatibility and to match the W3C standard
  249. // cf http://www.w3.org/TR/DOM-Level-3-Events-key/
  250. '\b': 'Backspace',
  251. '\t': 'Tab',
  252. '\x7F': 'Delete',
  253. '\x1B': 'Escape',
  254. 'Del': 'Delete',
  255. 'Esc': 'Escape',
  256. 'Left': 'ArrowLeft',
  257. 'Right': 'ArrowRight',
  258. 'Up': 'ArrowUp',
  259. 'Down': 'ArrowDown',
  260. 'Menu': 'ContextMenu',
  261. 'Scroll': 'ScrollLock',
  262. 'Win': 'OS'
  263. };
  264. // There is a bug in Chrome for numeric keypad keys:
  265. // https://code.google.com/p/chromium/issues/detail?id=155654
  266. // 1, 2, 3 ... are reported as A, B, C ...
  267. var _chromeNumKeyPadMap = {
  268. 'A': '1',
  269. 'B': '2',
  270. 'C': '3',
  271. 'D': '4',
  272. 'E': '5',
  273. 'F': '6',
  274. 'G': '7',
  275. 'H': '8',
  276. 'I': '9',
  277. 'J': '*',
  278. 'K': '+',
  279. 'M': '-',
  280. 'N': '.',
  281. 'O': '/',
  282. '\x60': '0',
  283. '\x90': 'NumLock'
  284. };
  285. var nodeContains;
  286. if (_angular_core.ɵglobal['Node']) {
  287. nodeContains = _angular_core.ɵglobal['Node'].prototype.contains || function (node) {
  288. return !!(this.compareDocumentPosition(node) & 16);
  289. };
  290. }
  291. /**
  292. * A `DomAdapter` powered by full browser DOM APIs.
  293. *
  294. * \@security Tread carefully! Interacting with the DOM directly is dangerous and
  295. * can introduce XSS risks.
  296. */
  297. var BrowserDomAdapter = /** @class */ (function (_super) {
  298. __extends(BrowserDomAdapter, _super);
  299. function BrowserDomAdapter() {
  300. return _super !== null && _super.apply(this, arguments) || this;
  301. }
  302. /**
  303. * @param {?} templateHtml
  304. * @return {?}
  305. */
  306. BrowserDomAdapter.prototype.parse = /**
  307. * @param {?} templateHtml
  308. * @return {?}
  309. */
  310. function (templateHtml) { throw new Error('parse not implemented'); };
  311. /**
  312. * @return {?}
  313. */
  314. BrowserDomAdapter.makeCurrent = /**
  315. * @return {?}
  316. */
  317. function () { setRootDomAdapter(new BrowserDomAdapter()); };
  318. /**
  319. * @param {?} element
  320. * @param {?} name
  321. * @return {?}
  322. */
  323. BrowserDomAdapter.prototype.hasProperty = /**
  324. * @param {?} element
  325. * @param {?} name
  326. * @return {?}
  327. */
  328. function (element, name) { return name in element; };
  329. /**
  330. * @param {?} el
  331. * @param {?} name
  332. * @param {?} value
  333. * @return {?}
  334. */
  335. BrowserDomAdapter.prototype.setProperty = /**
  336. * @param {?} el
  337. * @param {?} name
  338. * @param {?} value
  339. * @return {?}
  340. */
  341. function (el, name, value) { (/** @type {?} */ (el))[name] = value; };
  342. /**
  343. * @param {?} el
  344. * @param {?} name
  345. * @return {?}
  346. */
  347. BrowserDomAdapter.prototype.getProperty = /**
  348. * @param {?} el
  349. * @param {?} name
  350. * @return {?}
  351. */
  352. function (el, name) { return (/** @type {?} */ (el))[name]; };
  353. /**
  354. * @param {?} el
  355. * @param {?} methodName
  356. * @param {?} args
  357. * @return {?}
  358. */
  359. BrowserDomAdapter.prototype.invoke = /**
  360. * @param {?} el
  361. * @param {?} methodName
  362. * @param {?} args
  363. * @return {?}
  364. */
  365. function (el, methodName, args) {
  366. (_a = (/** @type {?} */ (el)))[methodName].apply(_a, args);
  367. var _a;
  368. };
  369. // TODO(tbosch): move this into a separate environment class once we have it
  370. /**
  371. * @param {?} error
  372. * @return {?}
  373. */
  374. BrowserDomAdapter.prototype.logError = /**
  375. * @param {?} error
  376. * @return {?}
  377. */
  378. function (error) {
  379. if (window.console) {
  380. if (console.error) {
  381. console.error(error);
  382. }
  383. else {
  384. console.log(error);
  385. }
  386. }
  387. };
  388. /**
  389. * @param {?} error
  390. * @return {?}
  391. */
  392. BrowserDomAdapter.prototype.log = /**
  393. * @param {?} error
  394. * @return {?}
  395. */
  396. function (error) {
  397. if (window.console) {
  398. window.console.log && window.console.log(error);
  399. }
  400. };
  401. /**
  402. * @param {?} error
  403. * @return {?}
  404. */
  405. BrowserDomAdapter.prototype.logGroup = /**
  406. * @param {?} error
  407. * @return {?}
  408. */
  409. function (error) {
  410. if (window.console) {
  411. window.console.group && window.console.group(error);
  412. }
  413. };
  414. /**
  415. * @return {?}
  416. */
  417. BrowserDomAdapter.prototype.logGroupEnd = /**
  418. * @return {?}
  419. */
  420. function () {
  421. if (window.console) {
  422. window.console.groupEnd && window.console.groupEnd();
  423. }
  424. };
  425. Object.defineProperty(BrowserDomAdapter.prototype, "attrToPropMap", {
  426. get: /**
  427. * @return {?}
  428. */
  429. function () { return _attrToPropMap; },
  430. enumerable: true,
  431. configurable: true
  432. });
  433. /**
  434. * @param {?} nodeA
  435. * @param {?} nodeB
  436. * @return {?}
  437. */
  438. BrowserDomAdapter.prototype.contains = /**
  439. * @param {?} nodeA
  440. * @param {?} nodeB
  441. * @return {?}
  442. */
  443. function (nodeA, nodeB) { return nodeContains.call(nodeA, nodeB); };
  444. /**
  445. * @param {?} el
  446. * @param {?} selector
  447. * @return {?}
  448. */
  449. BrowserDomAdapter.prototype.querySelector = /**
  450. * @param {?} el
  451. * @param {?} selector
  452. * @return {?}
  453. */
  454. function (el, selector) { return el.querySelector(selector); };
  455. /**
  456. * @param {?} el
  457. * @param {?} selector
  458. * @return {?}
  459. */
  460. BrowserDomAdapter.prototype.querySelectorAll = /**
  461. * @param {?} el
  462. * @param {?} selector
  463. * @return {?}
  464. */
  465. function (el, selector) { return el.querySelectorAll(selector); };
  466. /**
  467. * @param {?} el
  468. * @param {?} evt
  469. * @param {?} listener
  470. * @return {?}
  471. */
  472. BrowserDomAdapter.prototype.on = /**
  473. * @param {?} el
  474. * @param {?} evt
  475. * @param {?} listener
  476. * @return {?}
  477. */
  478. function (el, evt, listener) { el.addEventListener(evt, listener, false); };
  479. /**
  480. * @param {?} el
  481. * @param {?} evt
  482. * @param {?} listener
  483. * @return {?}
  484. */
  485. BrowserDomAdapter.prototype.onAndCancel = /**
  486. * @param {?} el
  487. * @param {?} evt
  488. * @param {?} listener
  489. * @return {?}
  490. */
  491. function (el, evt, listener) {
  492. el.addEventListener(evt, listener, false);
  493. // Needed to follow Dart's subscription semantic, until fix of
  494. // https://code.google.com/p/dart/issues/detail?id=17406
  495. return function () { el.removeEventListener(evt, listener, false); };
  496. };
  497. /**
  498. * @param {?} el
  499. * @param {?} evt
  500. * @return {?}
  501. */
  502. BrowserDomAdapter.prototype.dispatchEvent = /**
  503. * @param {?} el
  504. * @param {?} evt
  505. * @return {?}
  506. */
  507. function (el, evt) { el.dispatchEvent(evt); };
  508. /**
  509. * @param {?} eventType
  510. * @return {?}
  511. */
  512. BrowserDomAdapter.prototype.createMouseEvent = /**
  513. * @param {?} eventType
  514. * @return {?}
  515. */
  516. function (eventType) {
  517. var /** @type {?} */ evt = this.getDefaultDocument().createEvent('MouseEvent');
  518. evt.initEvent(eventType, true, true);
  519. return evt;
  520. };
  521. /**
  522. * @param {?} eventType
  523. * @return {?}
  524. */
  525. BrowserDomAdapter.prototype.createEvent = /**
  526. * @param {?} eventType
  527. * @return {?}
  528. */
  529. function (eventType) {
  530. var /** @type {?} */ evt = this.getDefaultDocument().createEvent('Event');
  531. evt.initEvent(eventType, true, true);
  532. return evt;
  533. };
  534. /**
  535. * @param {?} evt
  536. * @return {?}
  537. */
  538. BrowserDomAdapter.prototype.preventDefault = /**
  539. * @param {?} evt
  540. * @return {?}
  541. */
  542. function (evt) {
  543. evt.preventDefault();
  544. evt.returnValue = false;
  545. };
  546. /**
  547. * @param {?} evt
  548. * @return {?}
  549. */
  550. BrowserDomAdapter.prototype.isPrevented = /**
  551. * @param {?} evt
  552. * @return {?}
  553. */
  554. function (evt) {
  555. return evt.defaultPrevented || evt.returnValue != null && !evt.returnValue;
  556. };
  557. /**
  558. * @param {?} el
  559. * @return {?}
  560. */
  561. BrowserDomAdapter.prototype.getInnerHTML = /**
  562. * @param {?} el
  563. * @return {?}
  564. */
  565. function (el) { return el.innerHTML; };
  566. /**
  567. * @param {?} el
  568. * @return {?}
  569. */
  570. BrowserDomAdapter.prototype.getTemplateContent = /**
  571. * @param {?} el
  572. * @return {?}
  573. */
  574. function (el) {
  575. return 'content' in el && this.isTemplateElement(el) ? (/** @type {?} */ (el)).content : null;
  576. };
  577. /**
  578. * @param {?} el
  579. * @return {?}
  580. */
  581. BrowserDomAdapter.prototype.getOuterHTML = /**
  582. * @param {?} el
  583. * @return {?}
  584. */
  585. function (el) { return el.outerHTML; };
  586. /**
  587. * @param {?} node
  588. * @return {?}
  589. */
  590. BrowserDomAdapter.prototype.nodeName = /**
  591. * @param {?} node
  592. * @return {?}
  593. */
  594. function (node) { return node.nodeName; };
  595. /**
  596. * @param {?} node
  597. * @return {?}
  598. */
  599. BrowserDomAdapter.prototype.nodeValue = /**
  600. * @param {?} node
  601. * @return {?}
  602. */
  603. function (node) { return node.nodeValue; };
  604. /**
  605. * @param {?} node
  606. * @return {?}
  607. */
  608. BrowserDomAdapter.prototype.type = /**
  609. * @param {?} node
  610. * @return {?}
  611. */
  612. function (node) { return node.type; };
  613. /**
  614. * @param {?} node
  615. * @return {?}
  616. */
  617. BrowserDomAdapter.prototype.content = /**
  618. * @param {?} node
  619. * @return {?}
  620. */
  621. function (node) {
  622. if (this.hasProperty(node, 'content')) {
  623. return (/** @type {?} */ (node)).content;
  624. }
  625. else {
  626. return node;
  627. }
  628. };
  629. /**
  630. * @param {?} el
  631. * @return {?}
  632. */
  633. BrowserDomAdapter.prototype.firstChild = /**
  634. * @param {?} el
  635. * @return {?}
  636. */
  637. function (el) { return el.firstChild; };
  638. /**
  639. * @param {?} el
  640. * @return {?}
  641. */
  642. BrowserDomAdapter.prototype.nextSibling = /**
  643. * @param {?} el
  644. * @return {?}
  645. */
  646. function (el) { return el.nextSibling; };
  647. /**
  648. * @param {?} el
  649. * @return {?}
  650. */
  651. BrowserDomAdapter.prototype.parentElement = /**
  652. * @param {?} el
  653. * @return {?}
  654. */
  655. function (el) { return el.parentNode; };
  656. /**
  657. * @param {?} el
  658. * @return {?}
  659. */
  660. BrowserDomAdapter.prototype.childNodes = /**
  661. * @param {?} el
  662. * @return {?}
  663. */
  664. function (el) { return el.childNodes; };
  665. /**
  666. * @param {?} el
  667. * @return {?}
  668. */
  669. BrowserDomAdapter.prototype.childNodesAsList = /**
  670. * @param {?} el
  671. * @return {?}
  672. */
  673. function (el) {
  674. var /** @type {?} */ childNodes = el.childNodes;
  675. var /** @type {?} */ res = new Array(childNodes.length);
  676. for (var /** @type {?} */ i = 0; i < childNodes.length; i++) {
  677. res[i] = childNodes[i];
  678. }
  679. return res;
  680. };
  681. /**
  682. * @param {?} el
  683. * @return {?}
  684. */
  685. BrowserDomAdapter.prototype.clearNodes = /**
  686. * @param {?} el
  687. * @return {?}
  688. */
  689. function (el) {
  690. while (el.firstChild) {
  691. el.removeChild(el.firstChild);
  692. }
  693. };
  694. /**
  695. * @param {?} el
  696. * @param {?} node
  697. * @return {?}
  698. */
  699. BrowserDomAdapter.prototype.appendChild = /**
  700. * @param {?} el
  701. * @param {?} node
  702. * @return {?}
  703. */
  704. function (el, node) { el.appendChild(node); };
  705. /**
  706. * @param {?} el
  707. * @param {?} node
  708. * @return {?}
  709. */
  710. BrowserDomAdapter.prototype.removeChild = /**
  711. * @param {?} el
  712. * @param {?} node
  713. * @return {?}
  714. */
  715. function (el, node) { el.removeChild(node); };
  716. /**
  717. * @param {?} el
  718. * @param {?} newChild
  719. * @param {?} oldChild
  720. * @return {?}
  721. */
  722. BrowserDomAdapter.prototype.replaceChild = /**
  723. * @param {?} el
  724. * @param {?} newChild
  725. * @param {?} oldChild
  726. * @return {?}
  727. */
  728. function (el, newChild, oldChild) { el.replaceChild(newChild, oldChild); };
  729. /**
  730. * @param {?} node
  731. * @return {?}
  732. */
  733. BrowserDomAdapter.prototype.remove = /**
  734. * @param {?} node
  735. * @return {?}
  736. */
  737. function (node) {
  738. if (node.parentNode) {
  739. node.parentNode.removeChild(node);
  740. }
  741. return node;
  742. };
  743. /**
  744. * @param {?} parent
  745. * @param {?} ref
  746. * @param {?} node
  747. * @return {?}
  748. */
  749. BrowserDomAdapter.prototype.insertBefore = /**
  750. * @param {?} parent
  751. * @param {?} ref
  752. * @param {?} node
  753. * @return {?}
  754. */
  755. function (parent, ref, node) { parent.insertBefore(node, ref); };
  756. /**
  757. * @param {?} parent
  758. * @param {?} ref
  759. * @param {?} nodes
  760. * @return {?}
  761. */
  762. BrowserDomAdapter.prototype.insertAllBefore = /**
  763. * @param {?} parent
  764. * @param {?} ref
  765. * @param {?} nodes
  766. * @return {?}
  767. */
  768. function (parent, ref, nodes) {
  769. nodes.forEach(function (n) { return parent.insertBefore(n, ref); });
  770. };
  771. /**
  772. * @param {?} parent
  773. * @param {?} ref
  774. * @param {?} node
  775. * @return {?}
  776. */
  777. BrowserDomAdapter.prototype.insertAfter = /**
  778. * @param {?} parent
  779. * @param {?} ref
  780. * @param {?} node
  781. * @return {?}
  782. */
  783. function (parent, ref, node) { parent.insertBefore(node, ref.nextSibling); };
  784. /**
  785. * @param {?} el
  786. * @param {?} value
  787. * @return {?}
  788. */
  789. BrowserDomAdapter.prototype.setInnerHTML = /**
  790. * @param {?} el
  791. * @param {?} value
  792. * @return {?}
  793. */
  794. function (el, value) { el.innerHTML = value; };
  795. /**
  796. * @param {?} el
  797. * @return {?}
  798. */
  799. BrowserDomAdapter.prototype.getText = /**
  800. * @param {?} el
  801. * @return {?}
  802. */
  803. function (el) { return el.textContent; };
  804. /**
  805. * @param {?} el
  806. * @param {?} value
  807. * @return {?}
  808. */
  809. BrowserDomAdapter.prototype.setText = /**
  810. * @param {?} el
  811. * @param {?} value
  812. * @return {?}
  813. */
  814. function (el, value) { el.textContent = value; };
  815. /**
  816. * @param {?} el
  817. * @return {?}
  818. */
  819. BrowserDomAdapter.prototype.getValue = /**
  820. * @param {?} el
  821. * @return {?}
  822. */
  823. function (el) { return el.value; };
  824. /**
  825. * @param {?} el
  826. * @param {?} value
  827. * @return {?}
  828. */
  829. BrowserDomAdapter.prototype.setValue = /**
  830. * @param {?} el
  831. * @param {?} value
  832. * @return {?}
  833. */
  834. function (el, value) { el.value = value; };
  835. /**
  836. * @param {?} el
  837. * @return {?}
  838. */
  839. BrowserDomAdapter.prototype.getChecked = /**
  840. * @param {?} el
  841. * @return {?}
  842. */
  843. function (el) { return el.checked; };
  844. /**
  845. * @param {?} el
  846. * @param {?} value
  847. * @return {?}
  848. */
  849. BrowserDomAdapter.prototype.setChecked = /**
  850. * @param {?} el
  851. * @param {?} value
  852. * @return {?}
  853. */
  854. function (el, value) { el.checked = value; };
  855. /**
  856. * @param {?} text
  857. * @return {?}
  858. */
  859. BrowserDomAdapter.prototype.createComment = /**
  860. * @param {?} text
  861. * @return {?}
  862. */
  863. function (text) { return this.getDefaultDocument().createComment(text); };
  864. /**
  865. * @param {?} html
  866. * @return {?}
  867. */
  868. BrowserDomAdapter.prototype.createTemplate = /**
  869. * @param {?} html
  870. * @return {?}
  871. */
  872. function (html) {
  873. var /** @type {?} */ t = this.getDefaultDocument().createElement('template');
  874. t.innerHTML = html;
  875. return t;
  876. };
  877. /**
  878. * @param {?} tagName
  879. * @param {?=} doc
  880. * @return {?}
  881. */
  882. BrowserDomAdapter.prototype.createElement = /**
  883. * @param {?} tagName
  884. * @param {?=} doc
  885. * @return {?}
  886. */
  887. function (tagName, doc) {
  888. doc = doc || this.getDefaultDocument();
  889. return doc.createElement(tagName);
  890. };
  891. /**
  892. * @param {?} ns
  893. * @param {?} tagName
  894. * @param {?=} doc
  895. * @return {?}
  896. */
  897. BrowserDomAdapter.prototype.createElementNS = /**
  898. * @param {?} ns
  899. * @param {?} tagName
  900. * @param {?=} doc
  901. * @return {?}
  902. */
  903. function (ns, tagName, doc) {
  904. doc = doc || this.getDefaultDocument();
  905. return doc.createElementNS(ns, tagName);
  906. };
  907. /**
  908. * @param {?} text
  909. * @param {?=} doc
  910. * @return {?}
  911. */
  912. BrowserDomAdapter.prototype.createTextNode = /**
  913. * @param {?} text
  914. * @param {?=} doc
  915. * @return {?}
  916. */
  917. function (text, doc) {
  918. doc = doc || this.getDefaultDocument();
  919. return doc.createTextNode(text);
  920. };
  921. /**
  922. * @param {?} attrName
  923. * @param {?} attrValue
  924. * @param {?=} doc
  925. * @return {?}
  926. */
  927. BrowserDomAdapter.prototype.createScriptTag = /**
  928. * @param {?} attrName
  929. * @param {?} attrValue
  930. * @param {?=} doc
  931. * @return {?}
  932. */
  933. function (attrName, attrValue, doc) {
  934. doc = doc || this.getDefaultDocument();
  935. var /** @type {?} */ el = /** @type {?} */ (doc.createElement('SCRIPT'));
  936. el.setAttribute(attrName, attrValue);
  937. return el;
  938. };
  939. /**
  940. * @param {?} css
  941. * @param {?=} doc
  942. * @return {?}
  943. */
  944. BrowserDomAdapter.prototype.createStyleElement = /**
  945. * @param {?} css
  946. * @param {?=} doc
  947. * @return {?}
  948. */
  949. function (css, doc) {
  950. doc = doc || this.getDefaultDocument();
  951. var /** @type {?} */ style = /** @type {?} */ (doc.createElement('style'));
  952. this.appendChild(style, this.createTextNode(css, doc));
  953. return style;
  954. };
  955. /**
  956. * @param {?} el
  957. * @return {?}
  958. */
  959. BrowserDomAdapter.prototype.createShadowRoot = /**
  960. * @param {?} el
  961. * @return {?}
  962. */
  963. function (el) { return (/** @type {?} */ (el)).createShadowRoot(); };
  964. /**
  965. * @param {?} el
  966. * @return {?}
  967. */
  968. BrowserDomAdapter.prototype.getShadowRoot = /**
  969. * @param {?} el
  970. * @return {?}
  971. */
  972. function (el) { return (/** @type {?} */ (el)).shadowRoot; };
  973. /**
  974. * @param {?} el
  975. * @return {?}
  976. */
  977. BrowserDomAdapter.prototype.getHost = /**
  978. * @param {?} el
  979. * @return {?}
  980. */
  981. function (el) { return (/** @type {?} */ (el)).host; };
  982. /**
  983. * @param {?} node
  984. * @return {?}
  985. */
  986. BrowserDomAdapter.prototype.clone = /**
  987. * @param {?} node
  988. * @return {?}
  989. */
  990. function (node) { return node.cloneNode(true); };
  991. /**
  992. * @param {?} element
  993. * @param {?} name
  994. * @return {?}
  995. */
  996. BrowserDomAdapter.prototype.getElementsByClassName = /**
  997. * @param {?} element
  998. * @param {?} name
  999. * @return {?}
  1000. */
  1001. function (element, name) {
  1002. return element.getElementsByClassName(name);
  1003. };
  1004. /**
  1005. * @param {?} element
  1006. * @param {?} name
  1007. * @return {?}
  1008. */
  1009. BrowserDomAdapter.prototype.getElementsByTagName = /**
  1010. * @param {?} element
  1011. * @param {?} name
  1012. * @return {?}
  1013. */
  1014. function (element, name) {
  1015. return element.getElementsByTagName(name);
  1016. };
  1017. /**
  1018. * @param {?} element
  1019. * @return {?}
  1020. */
  1021. BrowserDomAdapter.prototype.classList = /**
  1022. * @param {?} element
  1023. * @return {?}
  1024. */
  1025. function (element) { return Array.prototype.slice.call(element.classList, 0); };
  1026. /**
  1027. * @param {?} element
  1028. * @param {?} className
  1029. * @return {?}
  1030. */
  1031. BrowserDomAdapter.prototype.addClass = /**
  1032. * @param {?} element
  1033. * @param {?} className
  1034. * @return {?}
  1035. */
  1036. function (element, className) { element.classList.add(className); };
  1037. /**
  1038. * @param {?} element
  1039. * @param {?} className
  1040. * @return {?}
  1041. */
  1042. BrowserDomAdapter.prototype.removeClass = /**
  1043. * @param {?} element
  1044. * @param {?} className
  1045. * @return {?}
  1046. */
  1047. function (element, className) { element.classList.remove(className); };
  1048. /**
  1049. * @param {?} element
  1050. * @param {?} className
  1051. * @return {?}
  1052. */
  1053. BrowserDomAdapter.prototype.hasClass = /**
  1054. * @param {?} element
  1055. * @param {?} className
  1056. * @return {?}
  1057. */
  1058. function (element, className) {
  1059. return element.classList.contains(className);
  1060. };
  1061. /**
  1062. * @param {?} element
  1063. * @param {?} styleName
  1064. * @param {?} styleValue
  1065. * @return {?}
  1066. */
  1067. BrowserDomAdapter.prototype.setStyle = /**
  1068. * @param {?} element
  1069. * @param {?} styleName
  1070. * @param {?} styleValue
  1071. * @return {?}
  1072. */
  1073. function (element, styleName, styleValue) {
  1074. element.style[styleName] = styleValue;
  1075. };
  1076. /**
  1077. * @param {?} element
  1078. * @param {?} stylename
  1079. * @return {?}
  1080. */
  1081. BrowserDomAdapter.prototype.removeStyle = /**
  1082. * @param {?} element
  1083. * @param {?} stylename
  1084. * @return {?}
  1085. */
  1086. function (element, stylename) {
  1087. // IE requires '' instead of null
  1088. // see https://github.com/angular/angular/issues/7916
  1089. element.style[stylename] = '';
  1090. };
  1091. /**
  1092. * @param {?} element
  1093. * @param {?} stylename
  1094. * @return {?}
  1095. */
  1096. BrowserDomAdapter.prototype.getStyle = /**
  1097. * @param {?} element
  1098. * @param {?} stylename
  1099. * @return {?}
  1100. */
  1101. function (element, stylename) { return element.style[stylename]; };
  1102. /**
  1103. * @param {?} element
  1104. * @param {?} styleName
  1105. * @param {?=} styleValue
  1106. * @return {?}
  1107. */
  1108. BrowserDomAdapter.prototype.hasStyle = /**
  1109. * @param {?} element
  1110. * @param {?} styleName
  1111. * @param {?=} styleValue
  1112. * @return {?}
  1113. */
  1114. function (element, styleName, styleValue) {
  1115. var /** @type {?} */ value = this.getStyle(element, styleName) || '';
  1116. return styleValue ? value == styleValue : value.length > 0;
  1117. };
  1118. /**
  1119. * @param {?} element
  1120. * @return {?}
  1121. */
  1122. BrowserDomAdapter.prototype.tagName = /**
  1123. * @param {?} element
  1124. * @return {?}
  1125. */
  1126. function (element) { return element.tagName; };
  1127. /**
  1128. * @param {?} element
  1129. * @return {?}
  1130. */
  1131. BrowserDomAdapter.prototype.attributeMap = /**
  1132. * @param {?} element
  1133. * @return {?}
  1134. */
  1135. function (element) {
  1136. var /** @type {?} */ res = new Map();
  1137. var /** @type {?} */ elAttrs = element.attributes;
  1138. for (var /** @type {?} */ i = 0; i < elAttrs.length; i++) {
  1139. var /** @type {?} */ attrib = elAttrs.item(i);
  1140. res.set(attrib.name, attrib.value);
  1141. }
  1142. return res;
  1143. };
  1144. /**
  1145. * @param {?} element
  1146. * @param {?} attribute
  1147. * @return {?}
  1148. */
  1149. BrowserDomAdapter.prototype.hasAttribute = /**
  1150. * @param {?} element
  1151. * @param {?} attribute
  1152. * @return {?}
  1153. */
  1154. function (element, attribute) {
  1155. return element.hasAttribute(attribute);
  1156. };
  1157. /**
  1158. * @param {?} element
  1159. * @param {?} ns
  1160. * @param {?} attribute
  1161. * @return {?}
  1162. */
  1163. BrowserDomAdapter.prototype.hasAttributeNS = /**
  1164. * @param {?} element
  1165. * @param {?} ns
  1166. * @param {?} attribute
  1167. * @return {?}
  1168. */
  1169. function (element, ns, attribute) {
  1170. return element.hasAttributeNS(ns, attribute);
  1171. };
  1172. /**
  1173. * @param {?} element
  1174. * @param {?} attribute
  1175. * @return {?}
  1176. */
  1177. BrowserDomAdapter.prototype.getAttribute = /**
  1178. * @param {?} element
  1179. * @param {?} attribute
  1180. * @return {?}
  1181. */
  1182. function (element, attribute) {
  1183. return element.getAttribute(attribute);
  1184. };
  1185. /**
  1186. * @param {?} element
  1187. * @param {?} ns
  1188. * @param {?} name
  1189. * @return {?}
  1190. */
  1191. BrowserDomAdapter.prototype.getAttributeNS = /**
  1192. * @param {?} element
  1193. * @param {?} ns
  1194. * @param {?} name
  1195. * @return {?}
  1196. */
  1197. function (element, ns, name) {
  1198. return element.getAttributeNS(ns, name);
  1199. };
  1200. /**
  1201. * @param {?} element
  1202. * @param {?} name
  1203. * @param {?} value
  1204. * @return {?}
  1205. */
  1206. BrowserDomAdapter.prototype.setAttribute = /**
  1207. * @param {?} element
  1208. * @param {?} name
  1209. * @param {?} value
  1210. * @return {?}
  1211. */
  1212. function (element, name, value) { element.setAttribute(name, value); };
  1213. /**
  1214. * @param {?} element
  1215. * @param {?} ns
  1216. * @param {?} name
  1217. * @param {?} value
  1218. * @return {?}
  1219. */
  1220. BrowserDomAdapter.prototype.setAttributeNS = /**
  1221. * @param {?} element
  1222. * @param {?} ns
  1223. * @param {?} name
  1224. * @param {?} value
  1225. * @return {?}
  1226. */
  1227. function (element, ns, name, value) {
  1228. element.setAttributeNS(ns, name, value);
  1229. };
  1230. /**
  1231. * @param {?} element
  1232. * @param {?} attribute
  1233. * @return {?}
  1234. */
  1235. BrowserDomAdapter.prototype.removeAttribute = /**
  1236. * @param {?} element
  1237. * @param {?} attribute
  1238. * @return {?}
  1239. */
  1240. function (element, attribute) { element.removeAttribute(attribute); };
  1241. /**
  1242. * @param {?} element
  1243. * @param {?} ns
  1244. * @param {?} name
  1245. * @return {?}
  1246. */
  1247. BrowserDomAdapter.prototype.removeAttributeNS = /**
  1248. * @param {?} element
  1249. * @param {?} ns
  1250. * @param {?} name
  1251. * @return {?}
  1252. */
  1253. function (element, ns, name) {
  1254. element.removeAttributeNS(ns, name);
  1255. };
  1256. /**
  1257. * @param {?} el
  1258. * @return {?}
  1259. */
  1260. BrowserDomAdapter.prototype.templateAwareRoot = /**
  1261. * @param {?} el
  1262. * @return {?}
  1263. */
  1264. function (el) { return this.isTemplateElement(el) ? this.content(el) : el; };
  1265. /**
  1266. * @return {?}
  1267. */
  1268. BrowserDomAdapter.prototype.createHtmlDocument = /**
  1269. * @return {?}
  1270. */
  1271. function () {
  1272. return document.implementation.createHTMLDocument('fakeTitle');
  1273. };
  1274. /**
  1275. * @return {?}
  1276. */
  1277. BrowserDomAdapter.prototype.getDefaultDocument = /**
  1278. * @return {?}
  1279. */
  1280. function () { return document; };
  1281. /**
  1282. * @param {?} el
  1283. * @return {?}
  1284. */
  1285. BrowserDomAdapter.prototype.getBoundingClientRect = /**
  1286. * @param {?} el
  1287. * @return {?}
  1288. */
  1289. function (el) {
  1290. try {
  1291. return el.getBoundingClientRect();
  1292. }
  1293. catch (/** @type {?} */ e) {
  1294. return { top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0 };
  1295. }
  1296. };
  1297. /**
  1298. * @param {?} doc
  1299. * @return {?}
  1300. */
  1301. BrowserDomAdapter.prototype.getTitle = /**
  1302. * @param {?} doc
  1303. * @return {?}
  1304. */
  1305. function (doc) { return doc.title; };
  1306. /**
  1307. * @param {?} doc
  1308. * @param {?} newTitle
  1309. * @return {?}
  1310. */
  1311. BrowserDomAdapter.prototype.setTitle = /**
  1312. * @param {?} doc
  1313. * @param {?} newTitle
  1314. * @return {?}
  1315. */
  1316. function (doc, newTitle) { doc.title = newTitle || ''; };
  1317. /**
  1318. * @param {?} n
  1319. * @param {?} selector
  1320. * @return {?}
  1321. */
  1322. BrowserDomAdapter.prototype.elementMatches = /**
  1323. * @param {?} n
  1324. * @param {?} selector
  1325. * @return {?}
  1326. */
  1327. function (n, selector) {
  1328. if (this.isElementNode(n)) {
  1329. return n.matches && n.matches(selector) ||
  1330. n.msMatchesSelector && n.msMatchesSelector(selector) ||
  1331. n.webkitMatchesSelector && n.webkitMatchesSelector(selector);
  1332. }
  1333. return false;
  1334. };
  1335. /**
  1336. * @param {?} el
  1337. * @return {?}
  1338. */
  1339. BrowserDomAdapter.prototype.isTemplateElement = /**
  1340. * @param {?} el
  1341. * @return {?}
  1342. */
  1343. function (el) {
  1344. return this.isElementNode(el) && el.nodeName === 'TEMPLATE';
  1345. };
  1346. /**
  1347. * @param {?} node
  1348. * @return {?}
  1349. */
  1350. BrowserDomAdapter.prototype.isTextNode = /**
  1351. * @param {?} node
  1352. * @return {?}
  1353. */
  1354. function (node) { return node.nodeType === Node.TEXT_NODE; };
  1355. /**
  1356. * @param {?} node
  1357. * @return {?}
  1358. */
  1359. BrowserDomAdapter.prototype.isCommentNode = /**
  1360. * @param {?} node
  1361. * @return {?}
  1362. */
  1363. function (node) { return node.nodeType === Node.COMMENT_NODE; };
  1364. /**
  1365. * @param {?} node
  1366. * @return {?}
  1367. */
  1368. BrowserDomAdapter.prototype.isElementNode = /**
  1369. * @param {?} node
  1370. * @return {?}
  1371. */
  1372. function (node) { return node.nodeType === Node.ELEMENT_NODE; };
  1373. /**
  1374. * @param {?} node
  1375. * @return {?}
  1376. */
  1377. BrowserDomAdapter.prototype.hasShadowRoot = /**
  1378. * @param {?} node
  1379. * @return {?}
  1380. */
  1381. function (node) {
  1382. return node.shadowRoot != null && node instanceof HTMLElement;
  1383. };
  1384. /**
  1385. * @param {?} node
  1386. * @return {?}
  1387. */
  1388. BrowserDomAdapter.prototype.isShadowRoot = /**
  1389. * @param {?} node
  1390. * @return {?}
  1391. */
  1392. function (node) { return node instanceof DocumentFragment; };
  1393. /**
  1394. * @param {?} node
  1395. * @return {?}
  1396. */
  1397. BrowserDomAdapter.prototype.importIntoDoc = /**
  1398. * @param {?} node
  1399. * @return {?}
  1400. */
  1401. function (node) { return document.importNode(this.templateAwareRoot(node), true); };
  1402. /**
  1403. * @param {?} node
  1404. * @return {?}
  1405. */
  1406. BrowserDomAdapter.prototype.adoptNode = /**
  1407. * @param {?} node
  1408. * @return {?}
  1409. */
  1410. function (node) { return document.adoptNode(node); };
  1411. /**
  1412. * @param {?} el
  1413. * @return {?}
  1414. */
  1415. BrowserDomAdapter.prototype.getHref = /**
  1416. * @param {?} el
  1417. * @return {?}
  1418. */
  1419. function (el) { return /** @type {?} */ ((el.getAttribute('href'))); };
  1420. /**
  1421. * @param {?} event
  1422. * @return {?}
  1423. */
  1424. BrowserDomAdapter.prototype.getEventKey = /**
  1425. * @param {?} event
  1426. * @return {?}
  1427. */
  1428. function (event) {
  1429. var /** @type {?} */ key = event.key;
  1430. if (key == null) {
  1431. key = event.keyIdentifier;
  1432. // keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and
  1433. // Safari cf
  1434. // http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces
  1435. if (key == null) {
  1436. return 'Unidentified';
  1437. }
  1438. if (key.startsWith('U+')) {
  1439. key = String.fromCharCode(parseInt(key.substring(2), 16));
  1440. if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
  1441. // There is a bug in Chrome for numeric keypad keys:
  1442. // https://code.google.com/p/chromium/issues/detail?id=155654
  1443. // 1, 2, 3 ... are reported as A, B, C ...
  1444. key = (/** @type {?} */ (_chromeNumKeyPadMap))[key];
  1445. }
  1446. }
  1447. }
  1448. return _keyMap[key] || key;
  1449. };
  1450. /**
  1451. * @param {?} doc
  1452. * @param {?} target
  1453. * @return {?}
  1454. */
  1455. BrowserDomAdapter.prototype.getGlobalEventTarget = /**
  1456. * @param {?} doc
  1457. * @param {?} target
  1458. * @return {?}
  1459. */
  1460. function (doc, target) {
  1461. if (target === 'window') {
  1462. return window;
  1463. }
  1464. if (target === 'document') {
  1465. return doc;
  1466. }
  1467. if (target === 'body') {
  1468. return doc.body;
  1469. }
  1470. return null;
  1471. };
  1472. /**
  1473. * @return {?}
  1474. */
  1475. BrowserDomAdapter.prototype.getHistory = /**
  1476. * @return {?}
  1477. */
  1478. function () { return window.history; };
  1479. /**
  1480. * @return {?}
  1481. */
  1482. BrowserDomAdapter.prototype.getLocation = /**
  1483. * @return {?}
  1484. */
  1485. function () { return window.location; };
  1486. /**
  1487. * @param {?} doc
  1488. * @return {?}
  1489. */
  1490. BrowserDomAdapter.prototype.getBaseHref = /**
  1491. * @param {?} doc
  1492. * @return {?}
  1493. */
  1494. function (doc) {
  1495. var /** @type {?} */ href = getBaseElementHref();
  1496. return href == null ? null : relativePath(href);
  1497. };
  1498. /**
  1499. * @return {?}
  1500. */
  1501. BrowserDomAdapter.prototype.resetBaseElement = /**
  1502. * @return {?}
  1503. */
  1504. function () { baseElement = null; };
  1505. /**
  1506. * @return {?}
  1507. */
  1508. BrowserDomAdapter.prototype.getUserAgent = /**
  1509. * @return {?}
  1510. */
  1511. function () { return window.navigator.userAgent; };
  1512. /**
  1513. * @param {?} element
  1514. * @param {?} name
  1515. * @param {?} value
  1516. * @return {?}
  1517. */
  1518. BrowserDomAdapter.prototype.setData = /**
  1519. * @param {?} element
  1520. * @param {?} name
  1521. * @param {?} value
  1522. * @return {?}
  1523. */
  1524. function (element, name, value) {
  1525. this.setAttribute(element, 'data-' + name, value);
  1526. };
  1527. /**
  1528. * @param {?} element
  1529. * @param {?} name
  1530. * @return {?}
  1531. */
  1532. BrowserDomAdapter.prototype.getData = /**
  1533. * @param {?} element
  1534. * @param {?} name
  1535. * @return {?}
  1536. */
  1537. function (element, name) {
  1538. return this.getAttribute(element, 'data-' + name);
  1539. };
  1540. /**
  1541. * @param {?} element
  1542. * @return {?}
  1543. */
  1544. BrowserDomAdapter.prototype.getComputedStyle = /**
  1545. * @param {?} element
  1546. * @return {?}
  1547. */
  1548. function (element) { return getComputedStyle(element); };
  1549. // TODO(tbosch): move this into a separate environment class once we have it
  1550. /**
  1551. * @return {?}
  1552. */
  1553. BrowserDomAdapter.prototype.supportsWebAnimation = /**
  1554. * @return {?}
  1555. */
  1556. function () {
  1557. return typeof (/** @type {?} */ (Element)).prototype['animate'] === 'function';
  1558. };
  1559. /**
  1560. * @return {?}
  1561. */
  1562. BrowserDomAdapter.prototype.performanceNow = /**
  1563. * @return {?}
  1564. */
  1565. function () {
  1566. // performance.now() is not available in all browsers, see
  1567. // http://caniuse.com/#search=performance.now
  1568. return window.performance && window.performance.now ? window.performance.now() :
  1569. new Date().getTime();
  1570. };
  1571. /**
  1572. * @return {?}
  1573. */
  1574. BrowserDomAdapter.prototype.supportsCookies = /**
  1575. * @return {?}
  1576. */
  1577. function () { return true; };
  1578. /**
  1579. * @param {?} name
  1580. * @return {?}
  1581. */
  1582. BrowserDomAdapter.prototype.getCookie = /**
  1583. * @param {?} name
  1584. * @return {?}
  1585. */
  1586. function (name) { return _angular_common.ɵparseCookieValue(document.cookie, name); };
  1587. /**
  1588. * @param {?} name
  1589. * @param {?} value
  1590. * @return {?}
  1591. */
  1592. BrowserDomAdapter.prototype.setCookie = /**
  1593. * @param {?} name
  1594. * @param {?} value
  1595. * @return {?}
  1596. */
  1597. function (name, value) {
  1598. // document.cookie is magical, assigning into it assigns/overrides one cookie value, but does
  1599. // not clear other cookies.
  1600. document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value);
  1601. };
  1602. return BrowserDomAdapter;
  1603. }(GenericBrowserDomAdapter));
  1604. var baseElement = null;
  1605. /**
  1606. * @return {?}
  1607. */
  1608. function getBaseElementHref() {
  1609. if (!baseElement) {
  1610. baseElement = /** @type {?} */ ((document.querySelector('base')));
  1611. if (!baseElement) {
  1612. return null;
  1613. }
  1614. }
  1615. return baseElement.getAttribute('href');
  1616. }
  1617. // based on urlUtils.js in AngularJS 1
  1618. var urlParsingNode;
  1619. /**
  1620. * @param {?} url
  1621. * @return {?}
  1622. */
  1623. function relativePath(url) {
  1624. if (!urlParsingNode) {
  1625. urlParsingNode = document.createElement('a');
  1626. }
  1627. urlParsingNode.setAttribute('href', url);
  1628. return (urlParsingNode.pathname.charAt(0) === '/') ? urlParsingNode.pathname :
  1629. '/' + urlParsingNode.pathname;
  1630. }
  1631. /**
  1632. * @fileoverview added by tsickle
  1633. * @suppress {checkTypes} checked by tsc
  1634. */
  1635. /**
  1636. * @license
  1637. * Copyright Google Inc. All Rights Reserved.
  1638. *
  1639. * Use of this source code is governed by an MIT-style license that can be
  1640. * found in the LICENSE file at https://angular.io/license
  1641. */
  1642. /**
  1643. * A DI Token representing the main rendering context. In a browser this is the DOM Document.
  1644. *
  1645. * Note: Document might not be available in the Application Context when Application and Rendering
  1646. * Contexts are not the same (e.g. when running the application into a Web Worker).
  1647. *
  1648. * @deprecated import from `\@angular/common` instead.
  1649. */
  1650. var DOCUMENT$1 = _angular_common.DOCUMENT;
  1651. /**
  1652. * @fileoverview added by tsickle
  1653. * @suppress {checkTypes} checked by tsc
  1654. */
  1655. /**
  1656. * @license
  1657. * Copyright Google Inc. All Rights Reserved.
  1658. *
  1659. * Use of this source code is governed by an MIT-style license that can be
  1660. * found in the LICENSE file at https://angular.io/license
  1661. */
  1662. /**
  1663. * @return {?}
  1664. */
  1665. function supportsState() {
  1666. return !!window.history.pushState;
  1667. }
  1668. /**
  1669. * @fileoverview added by tsickle
  1670. * @suppress {checkTypes} checked by tsc
  1671. */
  1672. /**
  1673. * @license
  1674. * Copyright Google Inc. All Rights Reserved.
  1675. *
  1676. * Use of this source code is governed by an MIT-style license that can be
  1677. * found in the LICENSE file at https://angular.io/license
  1678. */
  1679. /**
  1680. * `PlatformLocation` encapsulates all of the direct calls to platform APIs.
  1681. * This class should not be used directly by an application developer. Instead, use
  1682. * {\@link Location}.
  1683. */
  1684. var BrowserPlatformLocation = /** @class */ (function (_super) {
  1685. __extends(BrowserPlatformLocation, _super);
  1686. function BrowserPlatformLocation(_doc) {
  1687. var _this = _super.call(this) || this;
  1688. _this._doc = _doc;
  1689. _this._init();
  1690. return _this;
  1691. }
  1692. // This is moved to its own method so that `MockPlatformLocationStrategy` can overwrite it
  1693. /** @internal */
  1694. /**
  1695. * \@internal
  1696. * @return {?}
  1697. */
  1698. BrowserPlatformLocation.prototype._init = /**
  1699. * \@internal
  1700. * @return {?}
  1701. */
  1702. function () {
  1703. (/** @type {?} */ (this)).location = getDOM().getLocation();
  1704. this._history = getDOM().getHistory();
  1705. };
  1706. /**
  1707. * @return {?}
  1708. */
  1709. BrowserPlatformLocation.prototype.getBaseHrefFromDOM = /**
  1710. * @return {?}
  1711. */
  1712. function () { return /** @type {?} */ ((getDOM().getBaseHref(this._doc))); };
  1713. /**
  1714. * @param {?} fn
  1715. * @return {?}
  1716. */
  1717. BrowserPlatformLocation.prototype.onPopState = /**
  1718. * @param {?} fn
  1719. * @return {?}
  1720. */
  1721. function (fn) {
  1722. getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('popstate', fn, false);
  1723. };
  1724. /**
  1725. * @param {?} fn
  1726. * @return {?}
  1727. */
  1728. BrowserPlatformLocation.prototype.onHashChange = /**
  1729. * @param {?} fn
  1730. * @return {?}
  1731. */
  1732. function (fn) {
  1733. getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('hashchange', fn, false);
  1734. };
  1735. Object.defineProperty(BrowserPlatformLocation.prototype, "pathname", {
  1736. get: /**
  1737. * @return {?}
  1738. */
  1739. function () { return this.location.pathname; },
  1740. set: /**
  1741. * @param {?} newPath
  1742. * @return {?}
  1743. */
  1744. function (newPath) { this.location.pathname = newPath; },
  1745. enumerable: true,
  1746. configurable: true
  1747. });
  1748. Object.defineProperty(BrowserPlatformLocation.prototype, "search", {
  1749. get: /**
  1750. * @return {?}
  1751. */
  1752. function () { return this.location.search; },
  1753. enumerable: true,
  1754. configurable: true
  1755. });
  1756. Object.defineProperty(BrowserPlatformLocation.prototype, "hash", {
  1757. get: /**
  1758. * @return {?}
  1759. */
  1760. function () { return this.location.hash; },
  1761. enumerable: true,
  1762. configurable: true
  1763. });
  1764. /**
  1765. * @param {?} state
  1766. * @param {?} title
  1767. * @param {?} url
  1768. * @return {?}
  1769. */
  1770. BrowserPlatformLocation.prototype.pushState = /**
  1771. * @param {?} state
  1772. * @param {?} title
  1773. * @param {?} url
  1774. * @return {?}
  1775. */
  1776. function (state, title, url) {
  1777. if (supportsState()) {
  1778. this._history.pushState(state, title, url);
  1779. }
  1780. else {
  1781. this.location.hash = url;
  1782. }
  1783. };
  1784. /**
  1785. * @param {?} state
  1786. * @param {?} title
  1787. * @param {?} url
  1788. * @return {?}
  1789. */
  1790. BrowserPlatformLocation.prototype.replaceState = /**
  1791. * @param {?} state
  1792. * @param {?} title
  1793. * @param {?} url
  1794. * @return {?}
  1795. */
  1796. function (state, title, url) {
  1797. if (supportsState()) {
  1798. this._history.replaceState(state, title, url);
  1799. }
  1800. else {
  1801. this.location.hash = url;
  1802. }
  1803. };
  1804. /**
  1805. * @return {?}
  1806. */
  1807. BrowserPlatformLocation.prototype.forward = /**
  1808. * @return {?}
  1809. */
  1810. function () { this._history.forward(); };
  1811. /**
  1812. * @return {?}
  1813. */
  1814. BrowserPlatformLocation.prototype.back = /**
  1815. * @return {?}
  1816. */
  1817. function () { this._history.back(); };
  1818. BrowserPlatformLocation.decorators = [
  1819. { type: _angular_core.Injectable },
  1820. ];
  1821. /** @nocollapse */
  1822. BrowserPlatformLocation.ctorParameters = function () { return [
  1823. { type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1,] },] },
  1824. ]; };
  1825. return BrowserPlatformLocation;
  1826. }(_angular_common.PlatformLocation));
  1827. /**
  1828. * @fileoverview added by tsickle
  1829. * @suppress {checkTypes} checked by tsc
  1830. */
  1831. /**
  1832. * @license
  1833. * Copyright Google Inc. All Rights Reserved.
  1834. *
  1835. * Use of this source code is governed by an MIT-style license that can be
  1836. * found in the LICENSE file at https://angular.io/license
  1837. */
  1838. /**
  1839. * A service that can be used to get and add meta tags.
  1840. *
  1841. * \@experimental
  1842. */
  1843. var Meta = /** @class */ (function () {
  1844. function Meta(_doc) {
  1845. this._doc = _doc;
  1846. this._dom = getDOM();
  1847. }
  1848. /**
  1849. * @param {?} tag
  1850. * @param {?=} forceCreation
  1851. * @return {?}
  1852. */
  1853. Meta.prototype.addTag = /**
  1854. * @param {?} tag
  1855. * @param {?=} forceCreation
  1856. * @return {?}
  1857. */
  1858. function (tag, forceCreation) {
  1859. if (forceCreation === void 0) { forceCreation = false; }
  1860. if (!tag)
  1861. return null;
  1862. return this._getOrCreateElement(tag, forceCreation);
  1863. };
  1864. /**
  1865. * @param {?} tags
  1866. * @param {?=} forceCreation
  1867. * @return {?}
  1868. */
  1869. Meta.prototype.addTags = /**
  1870. * @param {?} tags
  1871. * @param {?=} forceCreation
  1872. * @return {?}
  1873. */
  1874. function (tags, forceCreation) {
  1875. var _this = this;
  1876. if (forceCreation === void 0) { forceCreation = false; }
  1877. if (!tags)
  1878. return [];
  1879. return tags.reduce(function (result, tag) {
  1880. if (tag) {
  1881. result.push(_this._getOrCreateElement(tag, forceCreation));
  1882. }
  1883. return result;
  1884. }, []);
  1885. };
  1886. /**
  1887. * @param {?} attrSelector
  1888. * @return {?}
  1889. */
  1890. Meta.prototype.getTag = /**
  1891. * @param {?} attrSelector
  1892. * @return {?}
  1893. */
  1894. function (attrSelector) {
  1895. if (!attrSelector)
  1896. return null;
  1897. return this._dom.querySelector(this._doc, "meta[" + attrSelector + "]") || null;
  1898. };
  1899. /**
  1900. * @param {?} attrSelector
  1901. * @return {?}
  1902. */
  1903. Meta.prototype.getTags = /**
  1904. * @param {?} attrSelector
  1905. * @return {?}
  1906. */
  1907. function (attrSelector) {
  1908. if (!attrSelector)
  1909. return [];
  1910. var /** @type {?} */ list = this._dom.querySelectorAll(this._doc, "meta[" + attrSelector + "]");
  1911. return list ? [].slice.call(list) : [];
  1912. };
  1913. /**
  1914. * @param {?} tag
  1915. * @param {?=} selector
  1916. * @return {?}
  1917. */
  1918. Meta.prototype.updateTag = /**
  1919. * @param {?} tag
  1920. * @param {?=} selector
  1921. * @return {?}
  1922. */
  1923. function (tag, selector) {
  1924. if (!tag)
  1925. return null;
  1926. selector = selector || this._parseSelector(tag);
  1927. var /** @type {?} */ meta = /** @type {?} */ ((this.getTag(selector)));
  1928. if (meta) {
  1929. return this._setMetaElementAttributes(tag, meta);
  1930. }
  1931. return this._getOrCreateElement(tag, true);
  1932. };
  1933. /**
  1934. * @param {?} attrSelector
  1935. * @return {?}
  1936. */
  1937. Meta.prototype.removeTag = /**
  1938. * @param {?} attrSelector
  1939. * @return {?}
  1940. */
  1941. function (attrSelector) { this.removeTagElement(/** @type {?} */ ((this.getTag(attrSelector)))); };
  1942. /**
  1943. * @param {?} meta
  1944. * @return {?}
  1945. */
  1946. Meta.prototype.removeTagElement = /**
  1947. * @param {?} meta
  1948. * @return {?}
  1949. */
  1950. function (meta) {
  1951. if (meta) {
  1952. this._dom.remove(meta);
  1953. }
  1954. };
  1955. /**
  1956. * @param {?} meta
  1957. * @param {?=} forceCreation
  1958. * @return {?}
  1959. */
  1960. Meta.prototype._getOrCreateElement = /**
  1961. * @param {?} meta
  1962. * @param {?=} forceCreation
  1963. * @return {?}
  1964. */
  1965. function (meta, forceCreation) {
  1966. if (forceCreation === void 0) { forceCreation = false; }
  1967. if (!forceCreation) {
  1968. var /** @type {?} */ selector = this._parseSelector(meta);
  1969. var /** @type {?} */ elem = /** @type {?} */ ((this.getTag(selector)));
  1970. // It's allowed to have multiple elements with the same name so it's not enough to
  1971. // just check that element with the same name already present on the page. We also need to
  1972. // check if element has tag attributes
  1973. if (elem && this._containsAttributes(meta, elem))
  1974. return elem;
  1975. }
  1976. var /** @type {?} */ element = /** @type {?} */ (this._dom.createElement('meta'));
  1977. this._setMetaElementAttributes(meta, element);
  1978. var /** @type {?} */ head = this._dom.getElementsByTagName(this._doc, 'head')[0];
  1979. this._dom.appendChild(head, element);
  1980. return element;
  1981. };
  1982. /**
  1983. * @param {?} tag
  1984. * @param {?} el
  1985. * @return {?}
  1986. */
  1987. Meta.prototype._setMetaElementAttributes = /**
  1988. * @param {?} tag
  1989. * @param {?} el
  1990. * @return {?}
  1991. */
  1992. function (tag, el) {
  1993. var _this = this;
  1994. Object.keys(tag).forEach(function (prop) { return _this._dom.setAttribute(el, prop, tag[prop]); });
  1995. return el;
  1996. };
  1997. /**
  1998. * @param {?} tag
  1999. * @return {?}
  2000. */
  2001. Meta.prototype._parseSelector = /**
  2002. * @param {?} tag
  2003. * @return {?}
  2004. */
  2005. function (tag) {
  2006. var /** @type {?} */ attr = tag.name ? 'name' : 'property';
  2007. return attr + "=\"" + tag[attr] + "\"";
  2008. };
  2009. /**
  2010. * @param {?} tag
  2011. * @param {?} elem
  2012. * @return {?}
  2013. */
  2014. Meta.prototype._containsAttributes = /**
  2015. * @param {?} tag
  2016. * @param {?} elem
  2017. * @return {?}
  2018. */
  2019. function (tag, elem) {
  2020. var _this = this;
  2021. return Object.keys(tag).every(function (key) { return _this._dom.getAttribute(elem, key) === tag[key]; });
  2022. };
  2023. Meta.decorators = [
  2024. { type: _angular_core.Injectable },
  2025. ];
  2026. /** @nocollapse */
  2027. Meta.ctorParameters = function () { return [
  2028. { type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1,] },] },
  2029. ]; };
  2030. return Meta;
  2031. }());
  2032. /**
  2033. * @fileoverview added by tsickle
  2034. * @suppress {checkTypes} checked by tsc
  2035. */
  2036. /**
  2037. * @license
  2038. * Copyright Google Inc. All Rights Reserved.
  2039. *
  2040. * Use of this source code is governed by an MIT-style license that can be
  2041. * found in the LICENSE file at https://angular.io/license
  2042. */
  2043. /**
  2044. * An id that identifies a particular application being bootstrapped, that should
  2045. * match across the client/server boundary.
  2046. */
  2047. var TRANSITION_ID = new _angular_core.InjectionToken('TRANSITION_ID');
  2048. /**
  2049. * @param {?} transitionId
  2050. * @param {?} document
  2051. * @param {?} injector
  2052. * @return {?}
  2053. */
  2054. function appInitializerFactory(transitionId, document, injector) {
  2055. return function () {
  2056. // Wait for all application initializers to be completed before removing the styles set by
  2057. // the server.
  2058. injector.get(_angular_core.ApplicationInitStatus).donePromise.then(function () {
  2059. var /** @type {?} */ dom = getDOM();
  2060. var /** @type {?} */ styles = Array.prototype.slice.apply(dom.querySelectorAll(document, "style[ng-transition]"));
  2061. styles.filter(function (el) { return dom.getAttribute(el, 'ng-transition') === transitionId; })
  2062. .forEach(function (el) { return dom.remove(el); });
  2063. });
  2064. };
  2065. }
  2066. var SERVER_TRANSITION_PROVIDERS = [
  2067. {
  2068. provide: _angular_core.APP_INITIALIZER,
  2069. useFactory: appInitializerFactory,
  2070. deps: [TRANSITION_ID, DOCUMENT$1, _angular_core.Injector],
  2071. multi: true
  2072. },
  2073. ];
  2074. /**
  2075. * @fileoverview added by tsickle
  2076. * @suppress {checkTypes} checked by tsc
  2077. */
  2078. /**
  2079. * @license
  2080. * Copyright Google Inc. All Rights Reserved.
  2081. *
  2082. * Use of this source code is governed by an MIT-style license that can be
  2083. * found in the LICENSE file at https://angular.io/license
  2084. */
  2085. var BrowserGetTestability = /** @class */ (function () {
  2086. function BrowserGetTestability() {
  2087. }
  2088. /**
  2089. * @return {?}
  2090. */
  2091. BrowserGetTestability.init = /**
  2092. * @return {?}
  2093. */
  2094. function () { _angular_core.setTestabilityGetter(new BrowserGetTestability()); };
  2095. /**
  2096. * @param {?} registry
  2097. * @return {?}
  2098. */
  2099. BrowserGetTestability.prototype.addToWindow = /**
  2100. * @param {?} registry
  2101. * @return {?}
  2102. */
  2103. function (registry) {
  2104. _angular_core.ɵglobal['getAngularTestability'] = function (elem, findInAncestors) {
  2105. if (findInAncestors === void 0) { findInAncestors = true; }
  2106. var /** @type {?} */ testability = registry.findTestabilityInTree(elem, findInAncestors);
  2107. if (testability == null) {
  2108. throw new Error('Could not find testability for element.');
  2109. }
  2110. return testability;
  2111. };
  2112. _angular_core.ɵglobal['getAllAngularTestabilities'] = function () { return registry.getAllTestabilities(); };
  2113. _angular_core.ɵglobal['getAllAngularRootElements'] = function () { return registry.getAllRootElements(); };
  2114. var /** @type {?} */ whenAllStable = function (callback /** TODO #9100 */) {
  2115. var /** @type {?} */ testabilities = _angular_core.ɵglobal['getAllAngularTestabilities']();
  2116. var /** @type {?} */ count = testabilities.length;
  2117. var /** @type {?} */ didWork = false;
  2118. var /** @type {?} */ decrement = function (didWork_ /** TODO #9100 */) {
  2119. didWork = didWork || didWork_;
  2120. count--;
  2121. if (count == 0) {
  2122. callback(didWork);
  2123. }
  2124. };
  2125. testabilities.forEach(function (testability /** TODO #9100 */) {
  2126. testability.whenStable(decrement);
  2127. });
  2128. };
  2129. if (!_angular_core.ɵglobal['frameworkStabilizers']) {
  2130. _angular_core.ɵglobal['frameworkStabilizers'] = [];
  2131. }
  2132. _angular_core.ɵglobal['frameworkStabilizers'].push(whenAllStable);
  2133. };
  2134. /**
  2135. * @param {?} registry
  2136. * @param {?} elem
  2137. * @param {?} findInAncestors
  2138. * @return {?}
  2139. */
  2140. BrowserGetTestability.prototype.findTestabilityInTree = /**
  2141. * @param {?} registry
  2142. * @param {?} elem
  2143. * @param {?} findInAncestors
  2144. * @return {?}
  2145. */
  2146. function (registry, elem, findInAncestors) {
  2147. if (elem == null) {
  2148. return null;
  2149. }
  2150. var /** @type {?} */ t = registry.getTestability(elem);
  2151. if (t != null) {
  2152. return t;
  2153. }
  2154. else if (!findInAncestors) {
  2155. return null;
  2156. }
  2157. if (getDOM().isShadowRoot(elem)) {
  2158. return this.findTestabilityInTree(registry, getDOM().getHost(elem), true);
  2159. }
  2160. return this.findTestabilityInTree(registry, getDOM().parentElement(elem), true);
  2161. };
  2162. return BrowserGetTestability;
  2163. }());
  2164. /**
  2165. * @fileoverview added by tsickle
  2166. * @suppress {checkTypes} checked by tsc
  2167. */
  2168. /**
  2169. * @license
  2170. * Copyright Google Inc. All Rights Reserved.
  2171. *
  2172. * Use of this source code is governed by an MIT-style license that can be
  2173. * found in the LICENSE file at https://angular.io/license
  2174. */
  2175. /**
  2176. * A service that can be used to get and set the title of a current HTML document.
  2177. *
  2178. * Since an Angular application can't be bootstrapped on the entire HTML document (`<html>` tag)
  2179. * it is not possible to bind to the `text` property of the `HTMLTitleElement` elements
  2180. * (representing the `<title>` tag). Instead, this service can be used to set and get the current
  2181. * title value.
  2182. *
  2183. * \@experimental
  2184. */
  2185. var Title = /** @class */ (function () {
  2186. function Title(_doc) {
  2187. this._doc = _doc;
  2188. }
  2189. /**
  2190. * Get the title of the current HTML document.
  2191. */
  2192. /**
  2193. * Get the title of the current HTML document.
  2194. * @return {?}
  2195. */
  2196. Title.prototype.getTitle = /**
  2197. * Get the title of the current HTML document.
  2198. * @return {?}
  2199. */
  2200. function () { return getDOM().getTitle(this._doc); };
  2201. /**
  2202. * Set the title of the current HTML document.
  2203. * @param newTitle
  2204. */
  2205. /**
  2206. * Set the title of the current HTML document.
  2207. * @param {?} newTitle
  2208. * @return {?}
  2209. */
  2210. Title.prototype.setTitle = /**
  2211. * Set the title of the current HTML document.
  2212. * @param {?} newTitle
  2213. * @return {?}
  2214. */
  2215. function (newTitle) { getDOM().setTitle(this._doc, newTitle); };
  2216. Title.decorators = [
  2217. { type: _angular_core.Injectable },
  2218. ];
  2219. /** @nocollapse */
  2220. Title.ctorParameters = function () { return [
  2221. { type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1,] },] },
  2222. ]; };
  2223. return Title;
  2224. }());
  2225. /**
  2226. * @fileoverview added by tsickle
  2227. * @suppress {checkTypes} checked by tsc
  2228. */
  2229. /**
  2230. * @license
  2231. * Copyright Google Inc. All Rights Reserved.
  2232. *
  2233. * Use of this source code is governed by an MIT-style license that can be
  2234. * found in the LICENSE file at https://angular.io/license
  2235. */
  2236. /**
  2237. * @param {?} input
  2238. * @return {?}
  2239. */
  2240. /**
  2241. * @param {?} input
  2242. * @return {?}
  2243. */
  2244. /**
  2245. * Exports the value under a given `name` in the global property `ng`. For example `ng.probe` if
  2246. * `name` is `'probe'`.
  2247. * @param {?} name Name under which it will be exported. Keep in mind this will be a property of the
  2248. * global `ng` object.
  2249. * @param {?} value The value to export.
  2250. * @return {?}
  2251. */
  2252. function exportNgVar(name, value) {
  2253. if (typeof COMPILED === 'undefined' || !COMPILED) {
  2254. // Note: we can't export `ng` when using closure enhanced optimization as:
  2255. // - closure declares globals itself for minified names, which sometimes clobber our `ng` global
  2256. // - we can't declare a closure extern as the namespace `ng` is already used within Google
  2257. // for typings for angularJS (via `goog.provide('ng....')`).
  2258. var /** @type {?} */ ng = _angular_core.ɵglobal['ng'] = (/** @type {?} */ (_angular_core.ɵglobal['ng'])) || {};
  2259. ng[name] = value;
  2260. }
  2261. }
  2262. /**
  2263. * @fileoverview added by tsickle
  2264. * @suppress {checkTypes} checked by tsc
  2265. */
  2266. /**
  2267. * @license
  2268. * Copyright Google Inc. All Rights Reserved.
  2269. *
  2270. * Use of this source code is governed by an MIT-style license that can be
  2271. * found in the LICENSE file at https://angular.io/license
  2272. */
  2273. var CORE_TOKENS = {
  2274. 'ApplicationRef': _angular_core.ApplicationRef,
  2275. 'NgZone': _angular_core.NgZone,
  2276. };
  2277. var INSPECT_GLOBAL_NAME = 'probe';
  2278. var CORE_TOKENS_GLOBAL_NAME = 'coreTokens';
  2279. /**
  2280. * Returns a {\@link DebugElement} for the given native DOM element, or
  2281. * null if the given native element does not have an Angular view associated
  2282. * with it.
  2283. * @param {?} element
  2284. * @return {?}
  2285. */
  2286. function inspectNativeElement(element) {
  2287. return _angular_core.getDebugNode(element);
  2288. }
  2289. /**
  2290. * @param {?} coreTokens
  2291. * @return {?}
  2292. */
  2293. function _createNgProbe(coreTokens) {
  2294. exportNgVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
  2295. exportNgVar(CORE_TOKENS_GLOBAL_NAME, __assign({}, CORE_TOKENS, _ngProbeTokensToMap(coreTokens || [])));
  2296. return function () { return inspectNativeElement; };
  2297. }
  2298. /**
  2299. * @param {?} tokens
  2300. * @return {?}
  2301. */
  2302. function _ngProbeTokensToMap(tokens) {
  2303. return tokens.reduce(function (prev, t) { return (prev[t.name] = t.token, prev); }, {});
  2304. }
  2305. /**
  2306. * Providers which support debugging Angular applications (e.g. via `ng.probe`).
  2307. */
  2308. var ELEMENT_PROBE_PROVIDERS = [
  2309. {
  2310. provide: _angular_core.APP_INITIALIZER,
  2311. useFactory: _createNgProbe,
  2312. deps: [
  2313. [_angular_core.NgProbeToken, new _angular_core.Optional()],
  2314. ],
  2315. multi: true,
  2316. },
  2317. ];
  2318. /**
  2319. * @fileoverview added by tsickle
  2320. * @suppress {checkTypes} checked by tsc
  2321. */
  2322. /**
  2323. * @license
  2324. * Copyright Google Inc. All Rights Reserved.
  2325. *
  2326. * Use of this source code is governed by an MIT-style license that can be
  2327. * found in the LICENSE file at https://angular.io/license
  2328. */
  2329. /**
  2330. * \@stable
  2331. */
  2332. var EVENT_MANAGER_PLUGINS = new _angular_core.InjectionToken('EventManagerPlugins');
  2333. /**
  2334. * \@stable
  2335. */
  2336. var EventManager = /** @class */ (function () {
  2337. function EventManager(plugins, _zone) {
  2338. var _this = this;
  2339. this._zone = _zone;
  2340. this._eventNameToPlugin = new Map();
  2341. plugins.forEach(function (p) { return p.manager = _this; });
  2342. this._plugins = plugins.slice().reverse();
  2343. }
  2344. /**
  2345. * @param {?} element
  2346. * @param {?} eventName
  2347. * @param {?} handler
  2348. * @return {?}
  2349. */
  2350. EventManager.prototype.addEventListener = /**
  2351. * @param {?} element
  2352. * @param {?} eventName
  2353. * @param {?} handler
  2354. * @return {?}
  2355. */
  2356. function (element, eventName, handler) {
  2357. var /** @type {?} */ plugin = this._findPluginFor(eventName);
  2358. return plugin.addEventListener(element, eventName, handler);
  2359. };
  2360. /**
  2361. * @param {?} target
  2362. * @param {?} eventName
  2363. * @param {?} handler
  2364. * @return {?}
  2365. */
  2366. EventManager.prototype.addGlobalEventListener = /**
  2367. * @param {?} target
  2368. * @param {?} eventName
  2369. * @param {?} handler
  2370. * @return {?}
  2371. */
  2372. function (target, eventName, handler) {
  2373. var /** @type {?} */ plugin = this._findPluginFor(eventName);
  2374. return plugin.addGlobalEventListener(target, eventName, handler);
  2375. };
  2376. /**
  2377. * @return {?}
  2378. */
  2379. EventManager.prototype.getZone = /**
  2380. * @return {?}
  2381. */
  2382. function () { return this._zone; };
  2383. /** @internal */
  2384. /**
  2385. * \@internal
  2386. * @param {?} eventName
  2387. * @return {?}
  2388. */
  2389. EventManager.prototype._findPluginFor = /**
  2390. * \@internal
  2391. * @param {?} eventName
  2392. * @return {?}
  2393. */
  2394. function (eventName) {
  2395. var /** @type {?} */ plugin = this._eventNameToPlugin.get(eventName);
  2396. if (plugin) {
  2397. return plugin;
  2398. }
  2399. var /** @type {?} */ plugins = this._plugins;
  2400. for (var /** @type {?} */ i = 0; i < plugins.length; i++) {
  2401. var /** @type {?} */ plugin_1 = plugins[i];
  2402. if (plugin_1.supports(eventName)) {
  2403. this._eventNameToPlugin.set(eventName, plugin_1);
  2404. return plugin_1;
  2405. }
  2406. }
  2407. throw new Error("No event manager plugin found for event " + eventName);
  2408. };
  2409. EventManager.decorators = [
  2410. { type: _angular_core.Injectable },
  2411. ];
  2412. /** @nocollapse */
  2413. EventManager.ctorParameters = function () { return [
  2414. { type: Array, decorators: [{ type: _angular_core.Inject, args: [EVENT_MANAGER_PLUGINS,] },] },
  2415. { type: _angular_core.NgZone, },
  2416. ]; };
  2417. return EventManager;
  2418. }());
  2419. /**
  2420. * @abstract
  2421. */
  2422. var EventManagerPlugin = /** @class */ (function () {
  2423. function EventManagerPlugin(_doc) {
  2424. this._doc = _doc;
  2425. }
  2426. /**
  2427. * @param {?} element
  2428. * @param {?} eventName
  2429. * @param {?} handler
  2430. * @return {?}
  2431. */
  2432. EventManagerPlugin.prototype.addGlobalEventListener = /**
  2433. * @param {?} element
  2434. * @param {?} eventName
  2435. * @param {?} handler
  2436. * @return {?}
  2437. */
  2438. function (element, eventName, handler) {
  2439. var /** @type {?} */ target = getDOM().getGlobalEventTarget(this._doc, element);
  2440. if (!target) {
  2441. throw new Error("Unsupported event target " + target + " for event " + eventName);
  2442. }
  2443. return this.addEventListener(target, eventName, handler);
  2444. };
  2445. return EventManagerPlugin;
  2446. }());
  2447. /**
  2448. * @fileoverview added by tsickle
  2449. * @suppress {checkTypes} checked by tsc
  2450. */
  2451. /**
  2452. * @license
  2453. * Copyright Google Inc. All Rights Reserved.
  2454. *
  2455. * Use of this source code is governed by an MIT-style license that can be
  2456. * found in the LICENSE file at https://angular.io/license
  2457. */
  2458. var SharedStylesHost = /** @class */ (function () {
  2459. function SharedStylesHost() {
  2460. /**
  2461. * \@internal
  2462. */
  2463. this._stylesSet = new Set();
  2464. }
  2465. /**
  2466. * @param {?} styles
  2467. * @return {?}
  2468. */
  2469. SharedStylesHost.prototype.addStyles = /**
  2470. * @param {?} styles
  2471. * @return {?}
  2472. */
  2473. function (styles) {
  2474. var _this = this;
  2475. var /** @type {?} */ additions = new Set();
  2476. styles.forEach(function (style) {
  2477. if (!_this._stylesSet.has(style)) {
  2478. _this._stylesSet.add(style);
  2479. additions.add(style);
  2480. }
  2481. });
  2482. this.onStylesAdded(additions);
  2483. };
  2484. /**
  2485. * @param {?} additions
  2486. * @return {?}
  2487. */
  2488. SharedStylesHost.prototype.onStylesAdded = /**
  2489. * @param {?} additions
  2490. * @return {?}
  2491. */
  2492. function (additions) { };
  2493. /**
  2494. * @return {?}
  2495. */
  2496. SharedStylesHost.prototype.getAllStyles = /**
  2497. * @return {?}
  2498. */
  2499. function () { return Array.from(this._stylesSet); };
  2500. SharedStylesHost.decorators = [
  2501. { type: _angular_core.Injectable },
  2502. ];
  2503. /** @nocollapse */
  2504. SharedStylesHost.ctorParameters = function () { return []; };
  2505. return SharedStylesHost;
  2506. }());
  2507. var DomSharedStylesHost = /** @class */ (function (_super) {
  2508. __extends(DomSharedStylesHost, _super);
  2509. function DomSharedStylesHost(_doc) {
  2510. var _this = _super.call(this) || this;
  2511. _this._doc = _doc;
  2512. _this._hostNodes = new Set();
  2513. _this._styleNodes = new Set();
  2514. _this._hostNodes.add(_doc.head);
  2515. return _this;
  2516. }
  2517. /**
  2518. * @param {?} styles
  2519. * @param {?} host
  2520. * @return {?}
  2521. */
  2522. DomSharedStylesHost.prototype._addStylesToHost = /**
  2523. * @param {?} styles
  2524. * @param {?} host
  2525. * @return {?}
  2526. */
  2527. function (styles, host) {
  2528. var _this = this;
  2529. styles.forEach(function (style) {
  2530. var /** @type {?} */ styleEl = _this._doc.createElement('style');
  2531. styleEl.textContent = style;
  2532. _this._styleNodes.add(host.appendChild(styleEl));
  2533. });
  2534. };
  2535. /**
  2536. * @param {?} hostNode
  2537. * @return {?}
  2538. */
  2539. DomSharedStylesHost.prototype.addHost = /**
  2540. * @param {?} hostNode
  2541. * @return {?}
  2542. */
  2543. function (hostNode) {
  2544. this._addStylesToHost(this._stylesSet, hostNode);
  2545. this._hostNodes.add(hostNode);
  2546. };
  2547. /**
  2548. * @param {?} hostNode
  2549. * @return {?}
  2550. */
  2551. DomSharedStylesHost.prototype.removeHost = /**
  2552. * @param {?} hostNode
  2553. * @return {?}
  2554. */
  2555. function (hostNode) { this._hostNodes.delete(hostNode); };
  2556. /**
  2557. * @param {?} additions
  2558. * @return {?}
  2559. */
  2560. DomSharedStylesHost.prototype.onStylesAdded = /**
  2561. * @param {?} additions
  2562. * @return {?}
  2563. */
  2564. function (additions) {
  2565. var _this = this;
  2566. this._hostNodes.forEach(function (hostNode) { return _this._addStylesToHost(additions, hostNode); });
  2567. };
  2568. /**
  2569. * @return {?}
  2570. */
  2571. DomSharedStylesHost.prototype.ngOnDestroy = /**
  2572. * @return {?}
  2573. */
  2574. function () { this._styleNodes.forEach(function (styleNode) { return getDOM().remove(styleNode); }); };
  2575. DomSharedStylesHost.decorators = [
  2576. { type: _angular_core.Injectable },
  2577. ];
  2578. /** @nocollapse */
  2579. DomSharedStylesHost.ctorParameters = function () { return [
  2580. { type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1,] },] },
  2581. ]; };
  2582. return DomSharedStylesHost;
  2583. }(SharedStylesHost));
  2584. /**
  2585. * @fileoverview added by tsickle
  2586. * @suppress {checkTypes} checked by tsc
  2587. */
  2588. /**
  2589. * @license
  2590. * Copyright Google Inc. All Rights Reserved.
  2591. *
  2592. * Use of this source code is governed by an MIT-style license that can be
  2593. * found in the LICENSE file at https://angular.io/license
  2594. */
  2595. var NAMESPACE_URIS = {
  2596. 'svg': 'http://www.w3.org/2000/svg',
  2597. 'xhtml': 'http://www.w3.org/1999/xhtml',
  2598. 'xlink': 'http://www.w3.org/1999/xlink',
  2599. 'xml': 'http://www.w3.org/XML/1998/namespace',
  2600. 'xmlns': 'http://www.w3.org/2000/xmlns/',
  2601. };
  2602. var COMPONENT_REGEX = /%COMP%/g;
  2603. var COMPONENT_VARIABLE = '%COMP%';
  2604. var HOST_ATTR = "_nghost-" + COMPONENT_VARIABLE;
  2605. var CONTENT_ATTR = "_ngcontent-" + COMPONENT_VARIABLE;
  2606. /**
  2607. * @param {?} componentShortId
  2608. * @return {?}
  2609. */
  2610. function shimContentAttribute(componentShortId) {
  2611. return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
  2612. }
  2613. /**
  2614. * @param {?} componentShortId
  2615. * @return {?}
  2616. */
  2617. function shimHostAttribute(componentShortId) {
  2618. return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
  2619. }
  2620. /**
  2621. * @param {?} compId
  2622. * @param {?} styles
  2623. * @param {?} target
  2624. * @return {?}
  2625. */
  2626. function flattenStyles(compId, styles, target) {
  2627. for (var /** @type {?} */ i = 0; i < styles.length; i++) {
  2628. var /** @type {?} */ style = styles[i];
  2629. if (Array.isArray(style)) {
  2630. flattenStyles(compId, style, target);
  2631. }
  2632. else {
  2633. style = style.replace(COMPONENT_REGEX, compId);
  2634. target.push(style);
  2635. }
  2636. }
  2637. return target;
  2638. }
  2639. /**
  2640. * @param {?} eventHandler
  2641. * @return {?}
  2642. */
  2643. function decoratePreventDefault(eventHandler) {
  2644. return function (event) {
  2645. var /** @type {?} */ allowDefaultBehavior = eventHandler(event);
  2646. if (allowDefaultBehavior === false) {
  2647. // TODO(tbosch): move preventDefault into event plugins...
  2648. event.preventDefault();
  2649. event.returnValue = false;
  2650. }
  2651. };
  2652. }
  2653. var DomRendererFactory2 = /** @class */ (function () {
  2654. function DomRendererFactory2(eventManager, sharedStylesHost) {
  2655. this.eventManager = eventManager;
  2656. this.sharedStylesHost = sharedStylesHost;
  2657. this.rendererByCompId = new Map();
  2658. this.defaultRenderer = new DefaultDomRenderer2(eventManager);
  2659. }
  2660. /**
  2661. * @param {?} element
  2662. * @param {?} type
  2663. * @return {?}
  2664. */
  2665. DomRendererFactory2.prototype.createRenderer = /**
  2666. * @param {?} element
  2667. * @param {?} type
  2668. * @return {?}
  2669. */
  2670. function (element, type) {
  2671. if (!element || !type) {
  2672. return this.defaultRenderer;
  2673. }
  2674. switch (type.encapsulation) {
  2675. case _angular_core.ViewEncapsulation.Emulated: {
  2676. var /** @type {?} */ renderer = this.rendererByCompId.get(type.id);
  2677. if (!renderer) {
  2678. renderer =
  2679. new EmulatedEncapsulationDomRenderer2(this.eventManager, this.sharedStylesHost, type);
  2680. this.rendererByCompId.set(type.id, renderer);
  2681. }
  2682. (/** @type {?} */ (renderer)).applyToHost(element);
  2683. return renderer;
  2684. }
  2685. case _angular_core.ViewEncapsulation.Native:
  2686. return new ShadowDomRenderer(this.eventManager, this.sharedStylesHost, element, type);
  2687. default: {
  2688. if (!this.rendererByCompId.has(type.id)) {
  2689. var /** @type {?} */ styles = flattenStyles(type.id, type.styles, []);
  2690. this.sharedStylesHost.addStyles(styles);
  2691. this.rendererByCompId.set(type.id, this.defaultRenderer);
  2692. }
  2693. return this.defaultRenderer;
  2694. }
  2695. }
  2696. };
  2697. /**
  2698. * @return {?}
  2699. */
  2700. DomRendererFactory2.prototype.begin = /**
  2701. * @return {?}
  2702. */
  2703. function () { };
  2704. /**
  2705. * @return {?}
  2706. */
  2707. DomRendererFactory2.prototype.end = /**
  2708. * @return {?}
  2709. */
  2710. function () { };
  2711. DomRendererFactory2.decorators = [
  2712. { type: _angular_core.Injectable },
  2713. ];
  2714. /** @nocollapse */
  2715. DomRendererFactory2.ctorParameters = function () { return [
  2716. { type: EventManager, },
  2717. { type: DomSharedStylesHost, },
  2718. ]; };
  2719. return DomRendererFactory2;
  2720. }());
  2721. var DefaultDomRenderer2 = /** @class */ (function () {
  2722. function DefaultDomRenderer2(eventManager) {
  2723. this.eventManager = eventManager;
  2724. this.data = Object.create(null);
  2725. }
  2726. /**
  2727. * @return {?}
  2728. */
  2729. DefaultDomRenderer2.prototype.destroy = /**
  2730. * @return {?}
  2731. */
  2732. function () { };
  2733. /**
  2734. * @param {?} name
  2735. * @param {?=} namespace
  2736. * @return {?}
  2737. */
  2738. DefaultDomRenderer2.prototype.createElement = /**
  2739. * @param {?} name
  2740. * @param {?=} namespace
  2741. * @return {?}
  2742. */
  2743. function (name, namespace) {
  2744. if (namespace) {
  2745. return document.createElementNS(NAMESPACE_URIS[namespace], name);
  2746. }
  2747. return document.createElement(name);
  2748. };
  2749. /**
  2750. * @param {?} value
  2751. * @return {?}
  2752. */
  2753. DefaultDomRenderer2.prototype.createComment = /**
  2754. * @param {?} value
  2755. * @return {?}
  2756. */
  2757. function (value) { return document.createComment(value); };
  2758. /**
  2759. * @param {?} value
  2760. * @return {?}
  2761. */
  2762. DefaultDomRenderer2.prototype.createText = /**
  2763. * @param {?} value
  2764. * @return {?}
  2765. */
  2766. function (value) { return document.createTextNode(value); };
  2767. /**
  2768. * @param {?} parent
  2769. * @param {?} newChild
  2770. * @return {?}
  2771. */
  2772. DefaultDomRenderer2.prototype.appendChild = /**
  2773. * @param {?} parent
  2774. * @param {?} newChild
  2775. * @return {?}
  2776. */
  2777. function (parent, newChild) { parent.appendChild(newChild); };
  2778. /**
  2779. * @param {?} parent
  2780. * @param {?} newChild
  2781. * @param {?} refChild
  2782. * @return {?}
  2783. */
  2784. DefaultDomRenderer2.prototype.insertBefore = /**
  2785. * @param {?} parent
  2786. * @param {?} newChild
  2787. * @param {?} refChild
  2788. * @return {?}
  2789. */
  2790. function (parent, newChild, refChild) {
  2791. if (parent) {
  2792. parent.insertBefore(newChild, refChild);
  2793. }
  2794. };
  2795. /**
  2796. * @param {?} parent
  2797. * @param {?} oldChild
  2798. * @return {?}
  2799. */
  2800. DefaultDomRenderer2.prototype.removeChild = /**
  2801. * @param {?} parent
  2802. * @param {?} oldChild
  2803. * @return {?}
  2804. */
  2805. function (parent, oldChild) {
  2806. if (parent) {
  2807. parent.removeChild(oldChild);
  2808. }
  2809. };
  2810. /**
  2811. * @param {?} selectorOrNode
  2812. * @return {?}
  2813. */
  2814. DefaultDomRenderer2.prototype.selectRootElement = /**
  2815. * @param {?} selectorOrNode
  2816. * @return {?}
  2817. */
  2818. function (selectorOrNode) {
  2819. var /** @type {?} */ el = typeof selectorOrNode === 'string' ? document.querySelector(selectorOrNode) :
  2820. selectorOrNode;
  2821. if (!el) {
  2822. throw new Error("The selector \"" + selectorOrNode + "\" did not match any elements");
  2823. }
  2824. el.textContent = '';
  2825. return el;
  2826. };
  2827. /**
  2828. * @param {?} node
  2829. * @return {?}
  2830. */
  2831. DefaultDomRenderer2.prototype.parentNode = /**
  2832. * @param {?} node
  2833. * @return {?}
  2834. */
  2835. function (node) { return node.parentNode; };
  2836. /**
  2837. * @param {?} node
  2838. * @return {?}
  2839. */
  2840. DefaultDomRenderer2.prototype.nextSibling = /**
  2841. * @param {?} node
  2842. * @return {?}
  2843. */
  2844. function (node) { return node.nextSibling; };
  2845. /**
  2846. * @param {?} el
  2847. * @param {?} name
  2848. * @param {?} value
  2849. * @param {?=} namespace
  2850. * @return {?}
  2851. */
  2852. DefaultDomRenderer2.prototype.setAttribute = /**
  2853. * @param {?} el
  2854. * @param {?} name
  2855. * @param {?} value
  2856. * @param {?=} namespace
  2857. * @return {?}
  2858. */
  2859. function (el, name, value, namespace) {
  2860. if (namespace) {
  2861. name = namespace + ":" + name;
  2862. var /** @type {?} */ namespaceUri = NAMESPACE_URIS[namespace];
  2863. if (namespaceUri) {
  2864. el.setAttributeNS(namespaceUri, name, value);
  2865. }
  2866. else {
  2867. el.setAttribute(name, value);
  2868. }
  2869. }
  2870. else {
  2871. el.setAttribute(name, value);
  2872. }
  2873. };
  2874. /**
  2875. * @param {?} el
  2876. * @param {?} name
  2877. * @param {?=} namespace
  2878. * @return {?}
  2879. */
  2880. DefaultDomRenderer2.prototype.removeAttribute = /**
  2881. * @param {?} el
  2882. * @param {?} name
  2883. * @param {?=} namespace
  2884. * @return {?}
  2885. */
  2886. function (el, name, namespace) {
  2887. if (namespace) {
  2888. var /** @type {?} */ namespaceUri = NAMESPACE_URIS[namespace];
  2889. if (namespaceUri) {
  2890. el.removeAttributeNS(namespaceUri, name);
  2891. }
  2892. else {
  2893. el.removeAttribute(namespace + ":" + name);
  2894. }
  2895. }
  2896. else {
  2897. el.removeAttribute(name);
  2898. }
  2899. };
  2900. /**
  2901. * @param {?} el
  2902. * @param {?} name
  2903. * @return {?}
  2904. */
  2905. DefaultDomRenderer2.prototype.addClass = /**
  2906. * @param {?} el
  2907. * @param {?} name
  2908. * @return {?}
  2909. */
  2910. function (el, name) { el.classList.add(name); };
  2911. /**
  2912. * @param {?} el
  2913. * @param {?} name
  2914. * @return {?}
  2915. */
  2916. DefaultDomRenderer2.prototype.removeClass = /**
  2917. * @param {?} el
  2918. * @param {?} name
  2919. * @return {?}
  2920. */
  2921. function (el, name) { el.classList.remove(name); };
  2922. /**
  2923. * @param {?} el
  2924. * @param {?} style
  2925. * @param {?} value
  2926. * @param {?} flags
  2927. * @return {?}
  2928. */
  2929. DefaultDomRenderer2.prototype.setStyle = /**
  2930. * @param {?} el
  2931. * @param {?} style
  2932. * @param {?} value
  2933. * @param {?} flags
  2934. * @return {?}
  2935. */
  2936. function (el, style, value, flags) {
  2937. if (flags & _angular_core.RendererStyleFlags2.DashCase) {
  2938. el.style.setProperty(style, value, !!(flags & _angular_core.RendererStyleFlags2.Important) ? 'important' : '');
  2939. }
  2940. else {
  2941. el.style[style] = value;
  2942. }
  2943. };
  2944. /**
  2945. * @param {?} el
  2946. * @param {?} style
  2947. * @param {?} flags
  2948. * @return {?}
  2949. */
  2950. DefaultDomRenderer2.prototype.removeStyle = /**
  2951. * @param {?} el
  2952. * @param {?} style
  2953. * @param {?} flags
  2954. * @return {?}
  2955. */
  2956. function (el, style, flags) {
  2957. if (flags & _angular_core.RendererStyleFlags2.DashCase) {
  2958. el.style.removeProperty(style);
  2959. }
  2960. else {
  2961. // IE requires '' instead of null
  2962. // see https://github.com/angular/angular/issues/7916
  2963. el.style[style] = '';
  2964. }
  2965. };
  2966. /**
  2967. * @param {?} el
  2968. * @param {?} name
  2969. * @param {?} value
  2970. * @return {?}
  2971. */
  2972. DefaultDomRenderer2.prototype.setProperty = /**
  2973. * @param {?} el
  2974. * @param {?} name
  2975. * @param {?} value
  2976. * @return {?}
  2977. */
  2978. function (el, name, value) {
  2979. checkNoSyntheticProp(name, 'property');
  2980. el[name] = value;
  2981. };
  2982. /**
  2983. * @param {?} node
  2984. * @param {?} value
  2985. * @return {?}
  2986. */
  2987. DefaultDomRenderer2.prototype.setValue = /**
  2988. * @param {?} node
  2989. * @param {?} value
  2990. * @return {?}
  2991. */
  2992. function (node, value) { node.nodeValue = value; };
  2993. /**
  2994. * @param {?} target
  2995. * @param {?} event
  2996. * @param {?} callback
  2997. * @return {?}
  2998. */
  2999. DefaultDomRenderer2.prototype.listen = /**
  3000. * @param {?} target
  3001. * @param {?} event
  3002. * @param {?} callback
  3003. * @return {?}
  3004. */
  3005. function (target, event, callback) {
  3006. checkNoSyntheticProp(event, 'listener');
  3007. if (typeof target === 'string') {
  3008. return /** @type {?} */ (this.eventManager.addGlobalEventListener(target, event, decoratePreventDefault(callback)));
  3009. }
  3010. return /** @type {?} */ ((this.eventManager.addEventListener(target, event, decoratePreventDefault(callback))));
  3011. };
  3012. return DefaultDomRenderer2;
  3013. }());
  3014. var AT_CHARCODE = '@'.charCodeAt(0);
  3015. /**
  3016. * @param {?} name
  3017. * @param {?} nameKind
  3018. * @return {?}
  3019. */
  3020. function checkNoSyntheticProp(name, nameKind) {
  3021. if (name.charCodeAt(0) === AT_CHARCODE) {
  3022. throw new Error("Found the synthetic " + nameKind + " " + name + ". Please include either \"BrowserAnimationsModule\" or \"NoopAnimationsModule\" in your application.");
  3023. }
  3024. }
  3025. var EmulatedEncapsulationDomRenderer2 = /** @class */ (function (_super) {
  3026. __extends(EmulatedEncapsulationDomRenderer2, _super);
  3027. function EmulatedEncapsulationDomRenderer2(eventManager, sharedStylesHost, component) {
  3028. var _this = _super.call(this, eventManager) || this;
  3029. _this.component = component;
  3030. var /** @type {?} */ styles = flattenStyles(component.id, component.styles, []);
  3031. sharedStylesHost.addStyles(styles);
  3032. _this.contentAttr = shimContentAttribute(component.id);
  3033. _this.hostAttr = shimHostAttribute(component.id);
  3034. return _this;
  3035. }
  3036. /**
  3037. * @param {?} element
  3038. * @return {?}
  3039. */
  3040. EmulatedEncapsulationDomRenderer2.prototype.applyToHost = /**
  3041. * @param {?} element
  3042. * @return {?}
  3043. */
  3044. function (element) { _super.prototype.setAttribute.call(this, element, this.hostAttr, ''); };
  3045. /**
  3046. * @param {?} parent
  3047. * @param {?} name
  3048. * @return {?}
  3049. */
  3050. EmulatedEncapsulationDomRenderer2.prototype.createElement = /**
  3051. * @param {?} parent
  3052. * @param {?} name
  3053. * @return {?}
  3054. */
  3055. function (parent, name) {
  3056. var /** @type {?} */ el = _super.prototype.createElement.call(this, parent, name);
  3057. _super.prototype.setAttribute.call(this, el, this.contentAttr, '');
  3058. return el;
  3059. };
  3060. return EmulatedEncapsulationDomRenderer2;
  3061. }(DefaultDomRenderer2));
  3062. var ShadowDomRenderer = /** @class */ (function (_super) {
  3063. __extends(ShadowDomRenderer, _super);
  3064. function ShadowDomRenderer(eventManager, sharedStylesHost, hostEl, component) {
  3065. var _this = _super.call(this, eventManager) || this;
  3066. _this.sharedStylesHost = sharedStylesHost;
  3067. _this.hostEl = hostEl;
  3068. _this.component = component;
  3069. _this.shadowRoot = (/** @type {?} */ (hostEl)).createShadowRoot();
  3070. _this.sharedStylesHost.addHost(_this.shadowRoot);
  3071. var /** @type {?} */ styles = flattenStyles(component.id, component.styles, []);
  3072. for (var /** @type {?} */ i = 0; i < styles.length; i++) {
  3073. var /** @type {?} */ styleEl = document.createElement('style');
  3074. styleEl.textContent = styles[i];
  3075. _this.shadowRoot.appendChild(styleEl);
  3076. }
  3077. return _this;
  3078. }
  3079. /**
  3080. * @param {?} node
  3081. * @return {?}
  3082. */
  3083. ShadowDomRenderer.prototype.nodeOrShadowRoot = /**
  3084. * @param {?} node
  3085. * @return {?}
  3086. */
  3087. function (node) { return node === this.hostEl ? this.shadowRoot : node; };
  3088. /**
  3089. * @return {?}
  3090. */
  3091. ShadowDomRenderer.prototype.destroy = /**
  3092. * @return {?}
  3093. */
  3094. function () { this.sharedStylesHost.removeHost(this.shadowRoot); };
  3095. /**
  3096. * @param {?} parent
  3097. * @param {?} newChild
  3098. * @return {?}
  3099. */
  3100. ShadowDomRenderer.prototype.appendChild = /**
  3101. * @param {?} parent
  3102. * @param {?} newChild
  3103. * @return {?}
  3104. */
  3105. function (parent, newChild) {
  3106. return _super.prototype.appendChild.call(this, this.nodeOrShadowRoot(parent), newChild);
  3107. };
  3108. /**
  3109. * @param {?} parent
  3110. * @param {?} newChild
  3111. * @param {?} refChild
  3112. * @return {?}
  3113. */
  3114. ShadowDomRenderer.prototype.insertBefore = /**
  3115. * @param {?} parent
  3116. * @param {?} newChild
  3117. * @param {?} refChild
  3118. * @return {?}
  3119. */
  3120. function (parent, newChild, refChild) {
  3121. return _super.prototype.insertBefore.call(this, this.nodeOrShadowRoot(parent), newChild, refChild);
  3122. };
  3123. /**
  3124. * @param {?} parent
  3125. * @param {?} oldChild
  3126. * @return {?}
  3127. */
  3128. ShadowDomRenderer.prototype.removeChild = /**
  3129. * @param {?} parent
  3130. * @param {?} oldChild
  3131. * @return {?}
  3132. */
  3133. function (parent, oldChild) {
  3134. return _super.prototype.removeChild.call(this, this.nodeOrShadowRoot(parent), oldChild);
  3135. };
  3136. /**
  3137. * @param {?} node
  3138. * @return {?}
  3139. */
  3140. ShadowDomRenderer.prototype.parentNode = /**
  3141. * @param {?} node
  3142. * @return {?}
  3143. */
  3144. function (node) {
  3145. return this.nodeOrShadowRoot(_super.prototype.parentNode.call(this, this.nodeOrShadowRoot(node)));
  3146. };
  3147. return ShadowDomRenderer;
  3148. }(DefaultDomRenderer2));
  3149. /**
  3150. * @fileoverview added by tsickle
  3151. * @suppress {checkTypes} checked by tsc
  3152. */
  3153. /**
  3154. * @license
  3155. * Copyright Google Inc. All Rights Reserved.
  3156. *
  3157. * Use of this source code is governed by an MIT-style license that can be
  3158. * found in the LICENSE file at https://angular.io/license
  3159. */
  3160. var ɵ0 = function (v) {
  3161. return '__zone_symbol__' + v;
  3162. };
  3163. /**
  3164. * Detect if Zone is present. If it is then use simple zone aware 'addEventListener'
  3165. * since Angular can do much more
  3166. * efficient bookkeeping than Zone can, because we have additional information. This speeds up
  3167. * addEventListener by 3x.
  3168. */
  3169. var __symbol__ = (typeof Zone !== 'undefined') && (/** @type {?} */ (Zone))['__symbol__'] || ɵ0;
  3170. var ADD_EVENT_LISTENER = __symbol__('addEventListener');
  3171. var REMOVE_EVENT_LISTENER = __symbol__('removeEventListener');
  3172. var symbolNames = {};
  3173. var FALSE = 'FALSE';
  3174. var ANGULAR = 'ANGULAR';
  3175. var NATIVE_ADD_LISTENER = 'addEventListener';
  3176. var NATIVE_REMOVE_LISTENER = 'removeEventListener';
  3177. // use the same symbol string which is used in zone.js
  3178. var stopSymbol = '__zone_symbol__propagationStopped';
  3179. var stopMethodSymbol = '__zone_symbol__stopImmediatePropagation';
  3180. var blackListedEvents = (typeof Zone !== 'undefined') && (/** @type {?} */ (Zone))[__symbol__('BLACK_LISTED_EVENTS')];
  3181. var blackListedMap;
  3182. if (blackListedEvents) {
  3183. blackListedMap = {};
  3184. blackListedEvents.forEach(function (eventName) { blackListedMap[eventName] = eventName; });
  3185. }
  3186. var isBlackListedEvent = function (eventName) {
  3187. if (!blackListedMap) {
  3188. return false;
  3189. }
  3190. return blackListedMap.hasOwnProperty(eventName);
  3191. };
  3192. // a global listener to handle all dom event,
  3193. // so we do not need to create a closure everytime
  3194. var globalListener = function (event) {
  3195. var /** @type {?} */ symbolName = symbolNames[event.type];
  3196. if (!symbolName) {
  3197. return;
  3198. }
  3199. var /** @type {?} */ taskDatas = this[symbolName];
  3200. if (!taskDatas) {
  3201. return;
  3202. }
  3203. var /** @type {?} */ args = [event];
  3204. if (taskDatas.length === 1) {
  3205. // if taskDatas only have one element, just invoke it
  3206. var /** @type {?} */ taskData = taskDatas[0];
  3207. if (taskData.zone !== Zone.current) {
  3208. // only use Zone.run when Zone.current not equals to stored zone
  3209. return taskData.zone.run(taskData.handler, this, args);
  3210. }
  3211. else {
  3212. return taskData.handler.apply(this, args);
  3213. }
  3214. }
  3215. else {
  3216. // copy tasks as a snapshot to avoid event handlers remove
  3217. // itself or others
  3218. var /** @type {?} */ copiedTasks = taskDatas.slice();
  3219. for (var /** @type {?} */ i = 0; i < copiedTasks.length; i++) {
  3220. // if other listener call event.stopImmediatePropagation
  3221. // just break
  3222. if ((/** @type {?} */ (event))[stopSymbol] === true) {
  3223. break;
  3224. }
  3225. var /** @type {?} */ taskData = copiedTasks[i];
  3226. if (taskData.zone !== Zone.current) {
  3227. // only use Zone.run when Zone.current not equals to stored zone
  3228. taskData.zone.run(taskData.handler, this, args);
  3229. }
  3230. else {
  3231. taskData.handler.apply(this, args);
  3232. }
  3233. }
  3234. }
  3235. };
  3236. var DomEventsPlugin = /** @class */ (function (_super) {
  3237. __extends(DomEventsPlugin, _super);
  3238. function DomEventsPlugin(doc, ngZone) {
  3239. var _this = _super.call(this, doc) || this;
  3240. _this.ngZone = ngZone;
  3241. _this.patchEvent();
  3242. return _this;
  3243. }
  3244. /**
  3245. * @return {?}
  3246. */
  3247. DomEventsPlugin.prototype.patchEvent = /**
  3248. * @return {?}
  3249. */
  3250. function () {
  3251. if (!Event || !Event.prototype) {
  3252. return;
  3253. }
  3254. if ((/** @type {?} */ (Event.prototype))[stopMethodSymbol]) {
  3255. // already patched by zone.js
  3256. return;
  3257. }
  3258. var /** @type {?} */ delegate = (/** @type {?} */ (Event.prototype))[stopMethodSymbol] =
  3259. Event.prototype.stopImmediatePropagation;
  3260. Event.prototype.stopImmediatePropagation = function () {
  3261. if (this) {
  3262. this[stopSymbol] = true;
  3263. }
  3264. // should call native delegate in case
  3265. // in some enviroment part of the application
  3266. // will not use the patched Event
  3267. delegate && delegate.apply(this, arguments);
  3268. };
  3269. };
  3270. // This plugin should come last in the list of plugins, because it accepts all
  3271. // events.
  3272. /**
  3273. * @param {?} eventName
  3274. * @return {?}
  3275. */
  3276. DomEventsPlugin.prototype.supports = /**
  3277. * @param {?} eventName
  3278. * @return {?}
  3279. */
  3280. function (eventName) { return true; };
  3281. /**
  3282. * @param {?} element
  3283. * @param {?} eventName
  3284. * @param {?} handler
  3285. * @return {?}
  3286. */
  3287. DomEventsPlugin.prototype.addEventListener = /**
  3288. * @param {?} element
  3289. * @param {?} eventName
  3290. * @param {?} handler
  3291. * @return {?}
  3292. */
  3293. function (element, eventName, handler) {
  3294. var _this = this;
  3295. /**
  3296. * This code is about to add a listener to the DOM. If Zone.js is present, than
  3297. * `addEventListener` has been patched. The patched code adds overhead in both
  3298. * memory and speed (3x slower) than native. For this reason if we detect that
  3299. * Zone.js is present we use a simple version of zone aware addEventListener instead.
  3300. * The result is faster registration and the zone will be restored.
  3301. * But ZoneSpec.onScheduleTask, ZoneSpec.onInvokeTask, ZoneSpec.onCancelTask
  3302. * will not be invoked
  3303. * We also do manual zone restoration in element.ts renderEventHandlerClosure method.
  3304. *
  3305. * NOTE: it is possible that the element is from different iframe, and so we
  3306. * have to check before we execute the method.
  3307. */
  3308. var /** @type {?} */ self = this;
  3309. var /** @type {?} */ zoneJsLoaded = element[ADD_EVENT_LISTENER];
  3310. var /** @type {?} */ callback = /** @type {?} */ (handler);
  3311. // if zonejs is loaded and current zone is not ngZone
  3312. // we keep Zone.current on target for later restoration.
  3313. if (zoneJsLoaded && (!_angular_core.NgZone.isInAngularZone() || isBlackListedEvent(eventName))) {
  3314. var /** @type {?} */ symbolName = symbolNames[eventName];
  3315. if (!symbolName) {
  3316. symbolName = symbolNames[eventName] = __symbol__(ANGULAR + eventName + FALSE);
  3317. }
  3318. var /** @type {?} */ taskDatas = (/** @type {?} */ (element))[symbolName];
  3319. var /** @type {?} */ globalListenerRegistered = taskDatas && taskDatas.length > 0;
  3320. if (!taskDatas) {
  3321. taskDatas = (/** @type {?} */ (element))[symbolName] = [];
  3322. }
  3323. var /** @type {?} */ zone = isBlackListedEvent(eventName) ? Zone.root : Zone.current;
  3324. if (taskDatas.length === 0) {
  3325. taskDatas.push({ zone: zone, handler: callback });
  3326. }
  3327. else {
  3328. var /** @type {?} */ callbackRegistered = false;
  3329. for (var /** @type {?} */ i = 0; i < taskDatas.length; i++) {
  3330. if (taskDatas[i].handler === callback) {
  3331. callbackRegistered = true;
  3332. break;
  3333. }
  3334. }
  3335. if (!callbackRegistered) {
  3336. taskDatas.push({ zone: zone, handler: callback });
  3337. }
  3338. }
  3339. if (!globalListenerRegistered) {
  3340. element[ADD_EVENT_LISTENER](eventName, globalListener, false);
  3341. }
  3342. }
  3343. else {
  3344. element[NATIVE_ADD_LISTENER](eventName, callback, false);
  3345. }
  3346. return function () { return _this.removeEventListener(element, eventName, callback); };
  3347. };
  3348. /**
  3349. * @param {?} target
  3350. * @param {?} eventName
  3351. * @param {?} callback
  3352. * @return {?}
  3353. */
  3354. DomEventsPlugin.prototype.removeEventListener = /**
  3355. * @param {?} target
  3356. * @param {?} eventName
  3357. * @param {?} callback
  3358. * @return {?}
  3359. */
  3360. function (target, eventName, callback) {
  3361. var /** @type {?} */ underlyingRemove = target[REMOVE_EVENT_LISTENER];
  3362. // zone.js not loaded, use native removeEventListener
  3363. if (!underlyingRemove) {
  3364. return target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
  3365. }
  3366. var /** @type {?} */ symbolName = symbolNames[eventName];
  3367. var /** @type {?} */ taskDatas = symbolName && target[symbolName];
  3368. if (!taskDatas) {
  3369. // addEventListener not using patched version
  3370. // just call native removeEventListener
  3371. return target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
  3372. }
  3373. // fix issue 20532, should be able to remove
  3374. // listener which was added inside of ngZone
  3375. var /** @type {?} */ found = false;
  3376. for (var /** @type {?} */ i = 0; i < taskDatas.length; i++) {
  3377. // remove listener from taskDatas if the callback equals
  3378. if (taskDatas[i].handler === callback) {
  3379. found = true;
  3380. taskDatas.splice(i, 1);
  3381. break;
  3382. }
  3383. }
  3384. if (found) {
  3385. if (taskDatas.length === 0) {
  3386. // all listeners are removed, we can remove the globalListener from target
  3387. underlyingRemove.apply(target, [eventName, globalListener, false]);
  3388. }
  3389. }
  3390. else {
  3391. // not found in taskDatas, the callback may be added inside of ngZone
  3392. // use native remove listener to remove the calback
  3393. target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
  3394. }
  3395. };
  3396. DomEventsPlugin.decorators = [
  3397. { type: _angular_core.Injectable },
  3398. ];
  3399. /** @nocollapse */
  3400. DomEventsPlugin.ctorParameters = function () { return [
  3401. { type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1,] },] },
  3402. { type: _angular_core.NgZone, },
  3403. ]; };
  3404. return DomEventsPlugin;
  3405. }(EventManagerPlugin));
  3406. /**
  3407. * @fileoverview added by tsickle
  3408. * @suppress {checkTypes} checked by tsc
  3409. */
  3410. /**
  3411. * @license
  3412. * Copyright Google Inc. All Rights Reserved.
  3413. *
  3414. * Use of this source code is governed by an MIT-style license that can be
  3415. * found in the LICENSE file at https://angular.io/license
  3416. */
  3417. var EVENT_NAMES = {
  3418. // pan
  3419. 'pan': true,
  3420. 'panstart': true,
  3421. 'panmove': true,
  3422. 'panend': true,
  3423. 'pancancel': true,
  3424. 'panleft': true,
  3425. 'panright': true,
  3426. 'panup': true,
  3427. 'pandown': true,
  3428. // pinch
  3429. 'pinch': true,
  3430. 'pinchstart': true,
  3431. 'pinchmove': true,
  3432. 'pinchend': true,
  3433. 'pinchcancel': true,
  3434. 'pinchin': true,
  3435. 'pinchout': true,
  3436. // press
  3437. 'press': true,
  3438. 'pressup': true,
  3439. // rotate
  3440. 'rotate': true,
  3441. 'rotatestart': true,
  3442. 'rotatemove': true,
  3443. 'rotateend': true,
  3444. 'rotatecancel': true,
  3445. // swipe
  3446. 'swipe': true,
  3447. 'swipeleft': true,
  3448. 'swiperight': true,
  3449. 'swipeup': true,
  3450. 'swipedown': true,
  3451. // tap
  3452. 'tap': true,
  3453. };
  3454. /**
  3455. * A DI token that you can use to provide{\@link HammerGestureConfig} to Angular. Use it to configure
  3456. * Hammer gestures.
  3457. *
  3458. * \@experimental
  3459. */
  3460. var HAMMER_GESTURE_CONFIG = new _angular_core.InjectionToken('HammerGestureConfig');
  3461. /**
  3462. * @record
  3463. */
  3464. /**
  3465. * \@experimental
  3466. */
  3467. var HammerGestureConfig = /** @class */ (function () {
  3468. function HammerGestureConfig() {
  3469. this.events = [];
  3470. this.overrides = {};
  3471. }
  3472. /**
  3473. * @param {?} element
  3474. * @return {?}
  3475. */
  3476. HammerGestureConfig.prototype.buildHammer = /**
  3477. * @param {?} element
  3478. * @return {?}
  3479. */
  3480. function (element) {
  3481. var /** @type {?} */ mc = new Hammer(element);
  3482. mc.get('pinch').set({ enable: true });
  3483. mc.get('rotate').set({ enable: true });
  3484. for (var /** @type {?} */ eventName in this.overrides) {
  3485. mc.get(eventName).set(this.overrides[eventName]);
  3486. }
  3487. return mc;
  3488. };
  3489. HammerGestureConfig.decorators = [
  3490. { type: _angular_core.Injectable },
  3491. ];
  3492. /** @nocollapse */
  3493. HammerGestureConfig.ctorParameters = function () { return []; };
  3494. return HammerGestureConfig;
  3495. }());
  3496. var HammerGesturesPlugin = /** @class */ (function (_super) {
  3497. __extends(HammerGesturesPlugin, _super);
  3498. function HammerGesturesPlugin(doc, _config) {
  3499. var _this = _super.call(this, doc) || this;
  3500. _this._config = _config;
  3501. return _this;
  3502. }
  3503. /**
  3504. * @param {?} eventName
  3505. * @return {?}
  3506. */
  3507. HammerGesturesPlugin.prototype.supports = /**
  3508. * @param {?} eventName
  3509. * @return {?}
  3510. */
  3511. function (eventName) {
  3512. if (!EVENT_NAMES.hasOwnProperty(eventName.toLowerCase()) && !this.isCustomEvent(eventName)) {
  3513. return false;
  3514. }
  3515. if (!(/** @type {?} */ (window)).Hammer) {
  3516. throw new Error("Hammer.js is not loaded, can not bind " + eventName + " event");
  3517. }
  3518. return true;
  3519. };
  3520. /**
  3521. * @param {?} element
  3522. * @param {?} eventName
  3523. * @param {?} handler
  3524. * @return {?}
  3525. */
  3526. HammerGesturesPlugin.prototype.addEventListener = /**
  3527. * @param {?} element
  3528. * @param {?} eventName
  3529. * @param {?} handler
  3530. * @return {?}
  3531. */
  3532. function (element, eventName, handler) {
  3533. var _this = this;
  3534. var /** @type {?} */ zone = this.manager.getZone();
  3535. eventName = eventName.toLowerCase();
  3536. return zone.runOutsideAngular(function () {
  3537. // Creating the manager bind events, must be done outside of angular
  3538. var /** @type {?} */ mc = _this._config.buildHammer(element);
  3539. var /** @type {?} */ callback = function (eventObj) {
  3540. zone.runGuarded(function () { handler(eventObj); });
  3541. };
  3542. mc.on(eventName, callback);
  3543. return function () { return mc.off(eventName, callback); };
  3544. });
  3545. };
  3546. /**
  3547. * @param {?} eventName
  3548. * @return {?}
  3549. */
  3550. HammerGesturesPlugin.prototype.isCustomEvent = /**
  3551. * @param {?} eventName
  3552. * @return {?}
  3553. */
  3554. function (eventName) { return this._config.events.indexOf(eventName) > -1; };
  3555. HammerGesturesPlugin.decorators = [
  3556. { type: _angular_core.Injectable },
  3557. ];
  3558. /** @nocollapse */
  3559. HammerGesturesPlugin.ctorParameters = function () { return [
  3560. { type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1,] },] },
  3561. { type: HammerGestureConfig, decorators: [{ type: _angular_core.Inject, args: [HAMMER_GESTURE_CONFIG,] },] },
  3562. ]; };
  3563. return HammerGesturesPlugin;
  3564. }(EventManagerPlugin));
  3565. /**
  3566. * @fileoverview added by tsickle
  3567. * @suppress {checkTypes} checked by tsc
  3568. */
  3569. /**
  3570. * @license
  3571. * Copyright Google Inc. All Rights Reserved.
  3572. *
  3573. * Use of this source code is governed by an MIT-style license that can be
  3574. * found in the LICENSE file at https://angular.io/license
  3575. */
  3576. var MODIFIER_KEYS = ['alt', 'control', 'meta', 'shift'];
  3577. var ɵ0$1 = function (event) { return event.altKey; };
  3578. var ɵ1$1 = function (event) { return event.ctrlKey; };
  3579. var ɵ2$1 = function (event) { return event.metaKey; };
  3580. var ɵ3 = function (event) { return event.shiftKey; };
  3581. var MODIFIER_KEY_GETTERS = {
  3582. 'alt': ɵ0$1,
  3583. 'control': ɵ1$1,
  3584. 'meta': ɵ2$1,
  3585. 'shift': ɵ3
  3586. };
  3587. /**
  3588. * \@experimental
  3589. */
  3590. var KeyEventsPlugin = /** @class */ (function (_super) {
  3591. __extends(KeyEventsPlugin, _super);
  3592. function KeyEventsPlugin(doc) {
  3593. return _super.call(this, doc) || this;
  3594. }
  3595. /**
  3596. * @param {?} eventName
  3597. * @return {?}
  3598. */
  3599. KeyEventsPlugin.prototype.supports = /**
  3600. * @param {?} eventName
  3601. * @return {?}
  3602. */
  3603. function (eventName) { return KeyEventsPlugin.parseEventName(eventName) != null; };
  3604. /**
  3605. * @param {?} element
  3606. * @param {?} eventName
  3607. * @param {?} handler
  3608. * @return {?}
  3609. */
  3610. KeyEventsPlugin.prototype.addEventListener = /**
  3611. * @param {?} element
  3612. * @param {?} eventName
  3613. * @param {?} handler
  3614. * @return {?}
  3615. */
  3616. function (element, eventName, handler) {
  3617. var /** @type {?} */ parsedEvent = /** @type {?} */ ((KeyEventsPlugin.parseEventName(eventName)));
  3618. var /** @type {?} */ outsideHandler = KeyEventsPlugin.eventCallback(parsedEvent['fullKey'], handler, this.manager.getZone());
  3619. return this.manager.getZone().runOutsideAngular(function () {
  3620. return getDOM().onAndCancel(element, parsedEvent['domEventName'], outsideHandler);
  3621. });
  3622. };
  3623. /**
  3624. * @param {?} eventName
  3625. * @return {?}
  3626. */
  3627. KeyEventsPlugin.parseEventName = /**
  3628. * @param {?} eventName
  3629. * @return {?}
  3630. */
  3631. function (eventName) {
  3632. var /** @type {?} */ parts = eventName.toLowerCase().split('.');
  3633. var /** @type {?} */ domEventName = parts.shift();
  3634. if ((parts.length === 0) || !(domEventName === 'keydown' || domEventName === 'keyup')) {
  3635. return null;
  3636. }
  3637. var /** @type {?} */ key = KeyEventsPlugin._normalizeKey(/** @type {?} */ ((parts.pop())));
  3638. var /** @type {?} */ fullKey = '';
  3639. MODIFIER_KEYS.forEach(function (modifierName) {
  3640. var /** @type {?} */ index = parts.indexOf(modifierName);
  3641. if (index > -1) {
  3642. parts.splice(index, 1);
  3643. fullKey += modifierName + '.';
  3644. }
  3645. });
  3646. fullKey += key;
  3647. if (parts.length != 0 || key.length === 0) {
  3648. // returning null instead of throwing to let another plugin process the event
  3649. return null;
  3650. }
  3651. var /** @type {?} */ result = {};
  3652. result['domEventName'] = domEventName;
  3653. result['fullKey'] = fullKey;
  3654. return result;
  3655. };
  3656. /**
  3657. * @param {?} event
  3658. * @return {?}
  3659. */
  3660. KeyEventsPlugin.getEventFullKey = /**
  3661. * @param {?} event
  3662. * @return {?}
  3663. */
  3664. function (event) {
  3665. var /** @type {?} */ fullKey = '';
  3666. var /** @type {?} */ key = getDOM().getEventKey(event);
  3667. key = key.toLowerCase();
  3668. if (key === ' ') {
  3669. key = 'space'; // for readability
  3670. }
  3671. else if (key === '.') {
  3672. key = 'dot'; // because '.' is used as a separator in event names
  3673. }
  3674. MODIFIER_KEYS.forEach(function (modifierName) {
  3675. if (modifierName != key) {
  3676. var /** @type {?} */ modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
  3677. if (modifierGetter(event)) {
  3678. fullKey += modifierName + '.';
  3679. }
  3680. }
  3681. });
  3682. fullKey += key;
  3683. return fullKey;
  3684. };
  3685. /**
  3686. * @param {?} fullKey
  3687. * @param {?} handler
  3688. * @param {?} zone
  3689. * @return {?}
  3690. */
  3691. KeyEventsPlugin.eventCallback = /**
  3692. * @param {?} fullKey
  3693. * @param {?} handler
  3694. * @param {?} zone
  3695. * @return {?}
  3696. */
  3697. function (fullKey, handler, zone) {
  3698. return function (event /** TODO #9100 */) {
  3699. if (KeyEventsPlugin.getEventFullKey(event) === fullKey) {
  3700. zone.runGuarded(function () { return handler(event); });
  3701. }
  3702. };
  3703. };
  3704. /** @internal */
  3705. /**
  3706. * \@internal
  3707. * @param {?} keyName
  3708. * @return {?}
  3709. */
  3710. KeyEventsPlugin._normalizeKey = /**
  3711. * \@internal
  3712. * @param {?} keyName
  3713. * @return {?}
  3714. */
  3715. function (keyName) {
  3716. // TODO: switch to a Map if the mapping grows too much
  3717. switch (keyName) {
  3718. case 'esc':
  3719. return 'escape';
  3720. default:
  3721. return keyName;
  3722. }
  3723. };
  3724. KeyEventsPlugin.decorators = [
  3725. { type: _angular_core.Injectable },
  3726. ];
  3727. /** @nocollapse */
  3728. KeyEventsPlugin.ctorParameters = function () { return [
  3729. { type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1,] },] },
  3730. ]; };
  3731. return KeyEventsPlugin;
  3732. }(EventManagerPlugin));
  3733. /**
  3734. * @fileoverview added by tsickle
  3735. * @suppress {checkTypes} checked by tsc
  3736. */
  3737. /**
  3738. * @license
  3739. * Copyright Google Inc. All Rights Reserved.
  3740. *
  3741. * Use of this source code is governed by an MIT-style license that can be
  3742. * found in the LICENSE file at https://angular.io/license
  3743. */
  3744. /**
  3745. * This helper class is used to get hold of an inert tree of DOM elements containing dirty HTML
  3746. * that needs sanitizing.
  3747. * Depending upon browser support we must use one of three strategies for doing this.
  3748. * Support: Safari 10.x -> XHR strategy
  3749. * Support: Firefox -> DomParser strategy
  3750. * Default: InertDocument strategy
  3751. */
  3752. var InertBodyHelper = /** @class */ (function () {
  3753. function InertBodyHelper(defaultDoc, DOM) {
  3754. this.defaultDoc = defaultDoc;
  3755. this.DOM = DOM;
  3756. var /** @type {?} */ inertDocument = this.DOM.createHtmlDocument();
  3757. this.inertBodyElement = inertDocument.body;
  3758. if (this.inertBodyElement == null) {
  3759. // usually there should be only one body element in the document, but IE doesn't have any, so
  3760. // we need to create one.
  3761. var /** @type {?} */ inertHtml = this.DOM.createElement('html', inertDocument);
  3762. this.inertBodyElement = this.DOM.createElement('body', inertDocument);
  3763. this.DOM.appendChild(inertHtml, this.inertBodyElement);
  3764. this.DOM.appendChild(inertDocument, inertHtml);
  3765. }
  3766. this.DOM.setInnerHTML(this.inertBodyElement, '<svg><g onload="this.parentNode.remove()"></g></svg>');
  3767. if (this.inertBodyElement.querySelector && !this.inertBodyElement.querySelector('svg')) {
  3768. // We just hit the Safari 10.1 bug - which allows JS to run inside the SVG G element
  3769. // so use the XHR strategy.
  3770. this.getInertBodyElement = this.getInertBodyElement_XHR;
  3771. return;
  3772. }
  3773. this.DOM.setInnerHTML(this.inertBodyElement, '<svg><p><style><img src="</style><img src=x onerror=alert(1)//">');
  3774. if (this.inertBodyElement.querySelector && this.inertBodyElement.querySelector('svg img')) {
  3775. // We just hit the Firefox bug - which prevents the inner img JS from being sanitized
  3776. // so use the DOMParser strategy, if it is available.
  3777. // If the DOMParser is not available then we are not in Firefox (Server/WebWorker?) so we
  3778. // fall through to the default strategy below.
  3779. if (isDOMParserAvailable()) {
  3780. this.getInertBodyElement = this.getInertBodyElement_DOMParser;
  3781. return;
  3782. }
  3783. }
  3784. // None of the bugs were hit so it is safe for us to use the default InertDocument strategy
  3785. this.getInertBodyElement = this.getInertBodyElement_InertDocument;
  3786. }
  3787. /**
  3788. * Use XHR to create and fill an inert body element (on Safari 10.1)
  3789. * See
  3790. * https://github.com/cure53/DOMPurify/blob/a992d3a75031cb8bb032e5ea8399ba972bdf9a65/src/purify.js#L439-L449
  3791. * @param {?} html
  3792. * @return {?}
  3793. */
  3794. InertBodyHelper.prototype.getInertBodyElement_XHR = /**
  3795. * Use XHR to create and fill an inert body element (on Safari 10.1)
  3796. * See
  3797. * https://github.com/cure53/DOMPurify/blob/a992d3a75031cb8bb032e5ea8399ba972bdf9a65/src/purify.js#L439-L449
  3798. * @param {?} html
  3799. * @return {?}
  3800. */
  3801. function (html) {
  3802. // We add these extra elements to ensure that the rest of the content is parsed as expected
  3803. // e.g. leading whitespace is maintained and tags like `<meta>` do not get hoisted to the
  3804. // `<head>` tag.
  3805. html = '<body><remove></remove>' + html + '</body>';
  3806. try {
  3807. html = encodeURI(html);
  3808. }
  3809. catch (/** @type {?} */ e) {
  3810. return null;
  3811. }
  3812. var /** @type {?} */ xhr = new XMLHttpRequest();
  3813. xhr.responseType = 'document';
  3814. xhr.open('GET', 'data:text/html;charset=utf-8,' + html, false);
  3815. xhr.send(null);
  3816. var /** @type {?} */ body = xhr.response.body;
  3817. body.removeChild(/** @type {?} */ ((body.firstChild)));
  3818. return body;
  3819. };
  3820. /**
  3821. * Use DOMParser to create and fill an inert body element (on Firefox)
  3822. * See https://github.com/cure53/DOMPurify/releases/tag/0.6.7
  3823. *
  3824. * @param {?} html
  3825. * @return {?}
  3826. */
  3827. InertBodyHelper.prototype.getInertBodyElement_DOMParser = /**
  3828. * Use DOMParser to create and fill an inert body element (on Firefox)
  3829. * See https://github.com/cure53/DOMPurify/releases/tag/0.6.7
  3830. *
  3831. * @param {?} html
  3832. * @return {?}
  3833. */
  3834. function (html) {
  3835. // We add these extra elements to ensure that the rest of the content is parsed as expected
  3836. // e.g. leading whitespace is maintained and tags like `<meta>` do not get hoisted to the
  3837. // `<head>` tag.
  3838. html = '<body><remove></remove>' + html + '</body>';
  3839. try {
  3840. var /** @type {?} */ body = /** @type {?} */ (new (/** @type {?} */ (window))
  3841. .DOMParser()
  3842. .parseFromString(html, 'text/html')
  3843. .body);
  3844. body.removeChild(/** @type {?} */ ((body.firstChild)));
  3845. return body;
  3846. }
  3847. catch (/** @type {?} */ e) {
  3848. return null;
  3849. }
  3850. };
  3851. /**
  3852. * Use an HTML5 `template` element, if supported, or an inert body element created via
  3853. * `createHtmlDocument` to create and fill an inert DOM element.
  3854. * This is the default sane strategy to use if the browser does not require one of the specialised
  3855. * strategies above.
  3856. * @param {?} html
  3857. * @return {?}
  3858. */
  3859. InertBodyHelper.prototype.getInertBodyElement_InertDocument = /**
  3860. * Use an HTML5 `template` element, if supported, or an inert body element created via
  3861. * `createHtmlDocument` to create and fill an inert DOM element.
  3862. * This is the default sane strategy to use if the browser does not require one of the specialised
  3863. * strategies above.
  3864. * @param {?} html
  3865. * @return {?}
  3866. */
  3867. function (html) {
  3868. // Prefer using <template> element if supported.
  3869. var /** @type {?} */ templateEl = this.DOM.createElement('template');
  3870. if ('content' in templateEl) {
  3871. this.DOM.setInnerHTML(templateEl, html);
  3872. return templateEl;
  3873. }
  3874. this.DOM.setInnerHTML(this.inertBodyElement, html);
  3875. // Support: IE 9-11 only
  3876. // strip custom-namespaced attributes on IE<=11
  3877. if (this.defaultDoc.documentMode) {
  3878. this.stripCustomNsAttrs(this.inertBodyElement);
  3879. }
  3880. return this.inertBodyElement;
  3881. };
  3882. /**
  3883. * When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
  3884. * attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g.
  3885. * 'ns1:xlink:foo').
  3886. *
  3887. * This is undesirable since we don't want to allow any of these custom attributes. This method
  3888. * strips them all.
  3889. * @param {?} el
  3890. * @return {?}
  3891. */
  3892. InertBodyHelper.prototype.stripCustomNsAttrs = /**
  3893. * When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
  3894. * attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g.
  3895. * 'ns1:xlink:foo').
  3896. *
  3897. * This is undesirable since we don't want to allow any of these custom attributes. This method
  3898. * strips them all.
  3899. * @param {?} el
  3900. * @return {?}
  3901. */
  3902. function (el) {
  3903. var _this = this;
  3904. this.DOM.attributeMap(el).forEach(function (_, attrName) {
  3905. if (attrName === 'xmlns:ns1' || attrName.indexOf('ns1:') === 0) {
  3906. _this.DOM.removeAttribute(el, attrName);
  3907. }
  3908. });
  3909. for (var _i = 0, _a = this.DOM.childNodesAsList(el); _i < _a.length; _i++) {
  3910. var n = _a[_i];
  3911. if (this.DOM.isElementNode(n))
  3912. this.stripCustomNsAttrs(/** @type {?} */ (n));
  3913. }
  3914. };
  3915. return InertBodyHelper;
  3916. }());
  3917. /**
  3918. * We need to determine whether the DOMParser exists in the global context.
  3919. * The try-catch is because, on some browsers, trying to access this property
  3920. * on window can actually throw an error.
  3921. *
  3922. * @suppress {uselessCode}
  3923. * @return {?}
  3924. */
  3925. function isDOMParserAvailable() {
  3926. try {
  3927. return !!(/** @type {?} */ (window)).DOMParser;
  3928. }
  3929. catch (/** @type {?} */ e) {
  3930. return false;
  3931. }
  3932. }
  3933. /**
  3934. * @fileoverview added by tsickle
  3935. * @suppress {checkTypes} checked by tsc
  3936. */
  3937. /**
  3938. * @license
  3939. * Copyright Google Inc. All Rights Reserved.
  3940. *
  3941. * Use of this source code is governed by an MIT-style license that can be
  3942. * found in the LICENSE file at https://angular.io/license
  3943. */
  3944. /**
  3945. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  3946. *
  3947. * This regular expression matches a subset of URLs that will not cause script
  3948. * execution if used in URL context within a HTML document. Specifically, this
  3949. * regular expression matches if (comment from here on and regex copied from
  3950. * Soy's EscapingConventions):
  3951. * (1) Either a protocol in a whitelist (http, https, mailto or ftp).
  3952. * (2) or no protocol. A protocol must be followed by a colon. The below
  3953. * allows that by allowing colons only after one of the characters [/?#].
  3954. * A colon after a hash (#) must be in the fragment.
  3955. * Otherwise, a colon after a (?) must be in a query.
  3956. * Otherwise, a colon after a single solidus (/) must be in a path.
  3957. * Otherwise, a colon after a double solidus (//) must be in the authority
  3958. * (before port).
  3959. *
  3960. * The pattern disallows &, used in HTML entity declarations before
  3961. * one of the characters in [/?#]. This disallows HTML entities used in the
  3962. * protocol name, which should never happen, e.g. "h&#116;tp" for "http".
  3963. * It also disallows HTML entities in the first path part of a relative path,
  3964. * e.g. "foo&lt;bar/baz". Our existing escaping functions should not produce
  3965. * that. More importantly, it disallows masking of a colon,
  3966. * e.g. "javascript&#58;...".
  3967. *
  3968. * This regular expression was taken from the Closure sanitization library.
  3969. */
  3970. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  3971. /**
  3972. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  3973. */
  3974. var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+\/]+=*$/i;
  3975. /**
  3976. * @param {?} url
  3977. * @return {?}
  3978. */
  3979. function sanitizeUrl(url) {
  3980. url = String(url);
  3981. if (url.match(SAFE_URL_PATTERN) || url.match(DATA_URL_PATTERN))
  3982. return url;
  3983. if (_angular_core.isDevMode()) {
  3984. getDOM().log("WARNING: sanitizing unsafe URL value " + url + " (see http://g.co/ng/security#xss)");
  3985. }
  3986. return 'unsafe:' + url;
  3987. }
  3988. /**
  3989. * @param {?} srcset
  3990. * @return {?}
  3991. */
  3992. function sanitizeSrcset(srcset) {
  3993. srcset = String(srcset);
  3994. return srcset.split(',').map(function (srcset) { return sanitizeUrl(srcset.trim()); }).join(', ');
  3995. }
  3996. /**
  3997. * @fileoverview added by tsickle
  3998. * @suppress {checkTypes} checked by tsc
  3999. */
  4000. /**
  4001. * @license
  4002. * Copyright Google Inc. All Rights Reserved.
  4003. *
  4004. * Use of this source code is governed by an MIT-style license that can be
  4005. * found in the LICENSE file at https://angular.io/license
  4006. */
  4007. /**
  4008. * @param {?} tags
  4009. * @return {?}
  4010. */
  4011. function tagSet(tags) {
  4012. var /** @type {?} */ res = {};
  4013. for (var _i = 0, _a = tags.split(','); _i < _a.length; _i++) {
  4014. var t = _a[_i];
  4015. res[t] = true;
  4016. }
  4017. return res;
  4018. }
  4019. /**
  4020. * @param {...?} sets
  4021. * @return {?}
  4022. */
  4023. function merge() {
  4024. var sets = [];
  4025. for (var _i = 0; _i < arguments.length; _i++) {
  4026. sets[_i] = arguments[_i];
  4027. }
  4028. var /** @type {?} */ res = {};
  4029. for (var _a = 0, sets_1 = sets; _a < sets_1.length; _a++) {
  4030. var s = sets_1[_a];
  4031. for (var /** @type {?} */ v in s) {
  4032. if (s.hasOwnProperty(v))
  4033. res[v] = true;
  4034. }
  4035. }
  4036. return res;
  4037. }
  4038. // Good source of info about elements and attributes
  4039. // http://dev.w3.org/html5/spec/Overview.html#semantics
  4040. // http://simon.html5.org/html-elements
  4041. // Safe Void Elements - HTML5
  4042. // http://dev.w3.org/html5/spec/Overview.html#void-elements
  4043. var VOID_ELEMENTS = tagSet('area,br,col,hr,img,wbr');
  4044. // Elements that you can, intentionally, leave open (and which close themselves)
  4045. // http://dev.w3.org/html5/spec/Overview.html#optional-tags
  4046. var OPTIONAL_END_TAG_BLOCK_ELEMENTS = tagSet('colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr');
  4047. var OPTIONAL_END_TAG_INLINE_ELEMENTS = tagSet('rp,rt');
  4048. var OPTIONAL_END_TAG_ELEMENTS = merge(OPTIONAL_END_TAG_INLINE_ELEMENTS, OPTIONAL_END_TAG_BLOCK_ELEMENTS);
  4049. // Safe Block Elements - HTML5
  4050. var BLOCK_ELEMENTS = merge(OPTIONAL_END_TAG_BLOCK_ELEMENTS, tagSet('address,article,' +
  4051. 'aside,blockquote,caption,center,del,details,dialog,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,' +
  4052. 'h6,header,hgroup,hr,ins,main,map,menu,nav,ol,pre,section,summary,table,ul'));
  4053. // Inline Elements - HTML5
  4054. var INLINE_ELEMENTS = merge(OPTIONAL_END_TAG_INLINE_ELEMENTS, tagSet('a,abbr,acronym,audio,b,' +
  4055. 'bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,picture,q,ruby,rp,rt,s,' +
  4056. 'samp,small,source,span,strike,strong,sub,sup,time,track,tt,u,var,video'));
  4057. var VALID_ELEMENTS = merge(VOID_ELEMENTS, BLOCK_ELEMENTS, INLINE_ELEMENTS, OPTIONAL_END_TAG_ELEMENTS);
  4058. // Attributes that have href and hence need to be sanitized
  4059. var URI_ATTRS = tagSet('background,cite,href,itemtype,longdesc,poster,src,xlink:href');
  4060. // Attributes that have special href set hence need to be sanitized
  4061. var SRCSET_ATTRS = tagSet('srcset');
  4062. var HTML_ATTRS = tagSet('abbr,accesskey,align,alt,autoplay,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,' +
  4063. 'compact,controls,coords,datetime,default,dir,download,face,headers,height,hidden,hreflang,hspace,' +
  4064. 'ismap,itemscope,itemprop,kind,label,lang,language,loop,media,muted,nohref,nowrap,open,preload,rel,rev,role,rows,rowspan,rules,' +
  4065. 'scope,scrolling,shape,size,sizes,span,srclang,start,summary,tabindex,target,title,translate,type,usemap,' +
  4066. 'valign,value,vspace,width');
  4067. // NB: This currently consciously doesn't support SVG. SVG sanitization has had several security
  4068. // issues in the past, so it seems safer to leave it out if possible. If support for binding SVG via
  4069. // innerHTML is required, SVG attributes should be added here.
  4070. // NB: Sanitization does not allow <form> elements or other active elements (<button> etc). Those
  4071. // can be sanitized, but they increase security surface area without a legitimate use case, so they
  4072. // are left out here.
  4073. var VALID_ATTRS = merge(URI_ATTRS, SRCSET_ATTRS, HTML_ATTRS);
  4074. /**
  4075. * SanitizingHtmlSerializer serializes a DOM fragment, stripping out any unsafe elements and unsafe
  4076. * attributes.
  4077. */
  4078. var SanitizingHtmlSerializer = /** @class */ (function () {
  4079. function SanitizingHtmlSerializer() {
  4080. this.sanitizedSomething = false;
  4081. this.buf = [];
  4082. this.DOM = getDOM();
  4083. }
  4084. /**
  4085. * @param {?} el
  4086. * @return {?}
  4087. */
  4088. SanitizingHtmlSerializer.prototype.sanitizeChildren = /**
  4089. * @param {?} el
  4090. * @return {?}
  4091. */
  4092. function (el) {
  4093. // This cannot use a TreeWalker, as it has to run on Angular's various DOM adapters.
  4094. // However this code never accesses properties off of `document` before deleting its contents
  4095. // again, so it shouldn't be vulnerable to DOM clobbering.
  4096. var /** @type {?} */ current = /** @type {?} */ ((this.DOM.firstChild(el)));
  4097. while (current) {
  4098. if (this.DOM.isElementNode(current)) {
  4099. this.startElement(/** @type {?} */ (current));
  4100. }
  4101. else if (this.DOM.isTextNode(current)) {
  4102. this.chars(/** @type {?} */ ((this.DOM.nodeValue(current))));
  4103. }
  4104. else {
  4105. // Strip non-element, non-text nodes.
  4106. this.sanitizedSomething = true;
  4107. }
  4108. if (this.DOM.firstChild(current)) {
  4109. current = /** @type {?} */ ((this.DOM.firstChild(current)));
  4110. continue;
  4111. }
  4112. while (current) {
  4113. // Leaving the element. Walk up and to the right, closing tags as we go.
  4114. if (this.DOM.isElementNode(current)) {
  4115. this.endElement(/** @type {?} */ (current));
  4116. }
  4117. var /** @type {?} */ next = this.checkClobberedElement(current, /** @type {?} */ ((this.DOM.nextSibling(current))));
  4118. if (next) {
  4119. current = next;
  4120. break;
  4121. }
  4122. current = this.checkClobberedElement(current, /** @type {?} */ ((this.DOM.parentElement(current))));
  4123. }
  4124. }
  4125. return this.buf.join('');
  4126. };
  4127. /**
  4128. * @param {?} element
  4129. * @return {?}
  4130. */
  4131. SanitizingHtmlSerializer.prototype.startElement = /**
  4132. * @param {?} element
  4133. * @return {?}
  4134. */
  4135. function (element) {
  4136. var _this = this;
  4137. var /** @type {?} */ tagName = this.DOM.nodeName(element).toLowerCase();
  4138. if (!VALID_ELEMENTS.hasOwnProperty(tagName)) {
  4139. this.sanitizedSomething = true;
  4140. return;
  4141. }
  4142. this.buf.push('<');
  4143. this.buf.push(tagName);
  4144. this.DOM.attributeMap(element).forEach(function (value, attrName) {
  4145. var /** @type {?} */ lower = attrName.toLowerCase();
  4146. if (!VALID_ATTRS.hasOwnProperty(lower)) {
  4147. _this.sanitizedSomething = true;
  4148. return;
  4149. }
  4150. // TODO(martinprobst): Special case image URIs for data:image/...
  4151. if (URI_ATTRS[lower])
  4152. value = sanitizeUrl(value);
  4153. if (SRCSET_ATTRS[lower])
  4154. value = sanitizeSrcset(value);
  4155. _this.buf.push(' ');
  4156. _this.buf.push(attrName);
  4157. _this.buf.push('="');
  4158. _this.buf.push(encodeEntities(value));
  4159. _this.buf.push('"');
  4160. });
  4161. this.buf.push('>');
  4162. };
  4163. /**
  4164. * @param {?} current
  4165. * @return {?}
  4166. */
  4167. SanitizingHtmlSerializer.prototype.endElement = /**
  4168. * @param {?} current
  4169. * @return {?}
  4170. */
  4171. function (current) {
  4172. var /** @type {?} */ tagName = this.DOM.nodeName(current).toLowerCase();
  4173. if (VALID_ELEMENTS.hasOwnProperty(tagName) && !VOID_ELEMENTS.hasOwnProperty(tagName)) {
  4174. this.buf.push('</');
  4175. this.buf.push(tagName);
  4176. this.buf.push('>');
  4177. }
  4178. };
  4179. /**
  4180. * @param {?} chars
  4181. * @return {?}
  4182. */
  4183. SanitizingHtmlSerializer.prototype.chars = /**
  4184. * @param {?} chars
  4185. * @return {?}
  4186. */
  4187. function (chars) { this.buf.push(encodeEntities(chars)); };
  4188. /**
  4189. * @param {?} node
  4190. * @param {?} nextNode
  4191. * @return {?}
  4192. */
  4193. SanitizingHtmlSerializer.prototype.checkClobberedElement = /**
  4194. * @param {?} node
  4195. * @param {?} nextNode
  4196. * @return {?}
  4197. */
  4198. function (node, nextNode) {
  4199. if (nextNode && this.DOM.contains(node, nextNode)) {
  4200. throw new Error("Failed to sanitize html because the element is clobbered: " + this.DOM.getOuterHTML(node));
  4201. }
  4202. return nextNode;
  4203. };
  4204. return SanitizingHtmlSerializer;
  4205. }());
  4206. // Regular Expressions for parsing tags and attributes
  4207. var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
  4208. // ! to ~ is the ASCII range.
  4209. var NON_ALPHANUMERIC_REGEXP = /([^\#-~ |!])/g;
  4210. /**
  4211. * Escapes all potentially dangerous characters, so that the
  4212. * resulting string can be safely inserted into attribute or
  4213. * element text.
  4214. * @param {?} value
  4215. * @return {?}
  4216. */
  4217. function encodeEntities(value) {
  4218. return value.replace(/&/g, '&amp;')
  4219. .replace(SURROGATE_PAIR_REGEXP, function (match) {
  4220. var /** @type {?} */ hi = match.charCodeAt(0);
  4221. var /** @type {?} */ low = match.charCodeAt(1);
  4222. return '&#' + (((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000) + ';';
  4223. })
  4224. .replace(NON_ALPHANUMERIC_REGEXP, function (match) { return '&#' + match.charCodeAt(0) + ';'; })
  4225. .replace(/</g, '&lt;')
  4226. .replace(/>/g, '&gt;');
  4227. }
  4228. var inertBodyHelper;
  4229. /**
  4230. * Sanitizes the given unsafe, untrusted HTML fragment, and returns HTML text that is safe to add to
  4231. * the DOM in a browser environment.
  4232. * @param {?} defaultDoc
  4233. * @param {?} unsafeHtmlInput
  4234. * @return {?}
  4235. */
  4236. function sanitizeHtml(defaultDoc, unsafeHtmlInput) {
  4237. var /** @type {?} */ DOM = getDOM();
  4238. var /** @type {?} */ inertBodyElement = null;
  4239. try {
  4240. inertBodyHelper = inertBodyHelper || new InertBodyHelper(defaultDoc, DOM);
  4241. // Make sure unsafeHtml is actually a string (TypeScript types are not enforced at runtime).
  4242. var /** @type {?} */ unsafeHtml = unsafeHtmlInput ? String(unsafeHtmlInput) : '';
  4243. inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
  4244. // mXSS protection. Repeatedly parse the document to make sure it stabilizes, so that a browser
  4245. // trying to auto-correct incorrect HTML cannot cause formerly inert HTML to become dangerous.
  4246. var /** @type {?} */ mXSSAttempts = 5;
  4247. var /** @type {?} */ parsedHtml = unsafeHtml;
  4248. do {
  4249. if (mXSSAttempts === 0) {
  4250. throw new Error('Failed to sanitize html because the input is unstable');
  4251. }
  4252. mXSSAttempts--;
  4253. unsafeHtml = parsedHtml;
  4254. parsedHtml = DOM.getInnerHTML(inertBodyElement);
  4255. inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
  4256. } while (unsafeHtml !== parsedHtml);
  4257. var /** @type {?} */ sanitizer = new SanitizingHtmlSerializer();
  4258. var /** @type {?} */ safeHtml = sanitizer.sanitizeChildren(DOM.getTemplateContent(inertBodyElement) || inertBodyElement);
  4259. if (_angular_core.isDevMode() && sanitizer.sanitizedSomething) {
  4260. DOM.log('WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).');
  4261. }
  4262. return safeHtml;
  4263. }
  4264. finally {
  4265. // In case anything goes wrong, clear out inertElement to reset the entire DOM structure.
  4266. if (inertBodyElement) {
  4267. var /** @type {?} */ parent_1 = DOM.getTemplateContent(inertBodyElement) || inertBodyElement;
  4268. for (var _i = 0, _a = DOM.childNodesAsList(parent_1); _i < _a.length; _i++) {
  4269. var child = _a[_i];
  4270. DOM.removeChild(parent_1, child);
  4271. }
  4272. }
  4273. }
  4274. }
  4275. /**
  4276. * @fileoverview added by tsickle
  4277. * @suppress {checkTypes} checked by tsc
  4278. */
  4279. /**
  4280. * @license
  4281. * Copyright Google Inc. All Rights Reserved.
  4282. *
  4283. * Use of this source code is governed by an MIT-style license that can be
  4284. * found in the LICENSE file at https://angular.io/license
  4285. */
  4286. /**
  4287. * Regular expression for safe style values.
  4288. *
  4289. * Quotes (" and ') are allowed, but a check must be done elsewhere to ensure they're balanced.
  4290. *
  4291. * ',' allows multiple values to be assigned to the same property (e.g. background-attachment or
  4292. * font-family) and hence could allow multiple values to get injected, but that should pose no risk
  4293. * of XSS.
  4294. *
  4295. * The function expression checks only for XSS safety, not for CSS validity.
  4296. *
  4297. * This regular expression was taken from the Closure sanitization library, and augmented for
  4298. * transformation values.
  4299. */
  4300. var VALUES = '[-,."\'%_!# a-zA-Z0-9]+';
  4301. var TRANSFORMATION_FNS = '(?:matrix|translate|scale|rotate|skew|perspective)(?:X|Y|3d)?';
  4302. var COLOR_FNS = '(?:rgb|hsl)a?';
  4303. var GRADIENTS = '(?:repeating-)?(?:linear|radial)-gradient';
  4304. var CSS3_FNS = '(?:calc|attr)';
  4305. var FN_ARGS = '\\([-0-9.%, #a-zA-Z]+\\)';
  4306. var SAFE_STYLE_VALUE = new RegExp("^(" + VALUES + "|" +
  4307. ("(?:" + TRANSFORMATION_FNS + "|" + COLOR_FNS + "|" + GRADIENTS + "|" + CSS3_FNS + ")") +
  4308. (FN_ARGS + ")$"), 'g');
  4309. /**
  4310. * Matches a `url(...)` value with an arbitrary argument as long as it does
  4311. * not contain parentheses.
  4312. *
  4313. * The URL value still needs to be sanitized separately.
  4314. *
  4315. * `url(...)` values are a very common use case, e.g. for `background-image`. With carefully crafted
  4316. * CSS style rules, it is possible to construct an information leak with `url` values in CSS, e.g.
  4317. * by observing whether scroll bars are displayed, or character ranges used by a font face
  4318. * definition.
  4319. *
  4320. * Angular only allows binding CSS values (as opposed to entire CSS rules), so it is unlikely that
  4321. * binding a URL value without further cooperation from the page will cause an information leak, and
  4322. * if so, it is just a leak, not a full blown XSS vulnerability.
  4323. *
  4324. * Given the common use case, low likelihood of attack vector, and low impact of an attack, this
  4325. * code is permissive and allows URLs that sanitize otherwise.
  4326. */
  4327. var URL_RE = /^url\(([^)]+)\)$/;
  4328. /**
  4329. * Checks that quotes (" and ') are properly balanced inside a string. Assumes
  4330. * that neither escape (\) nor any other character that could result in
  4331. * breaking out of a string parsing context are allowed;
  4332. * see http://www.w3.org/TR/css3-syntax/#string-token-diagram.
  4333. *
  4334. * This code was taken from the Closure sanitization library.
  4335. * @param {?} value
  4336. * @return {?}
  4337. */
  4338. function hasBalancedQuotes(value) {
  4339. var /** @type {?} */ outsideSingle = true;
  4340. var /** @type {?} */ outsideDouble = true;
  4341. for (var /** @type {?} */ i = 0; i < value.length; i++) {
  4342. var /** @type {?} */ c = value.charAt(i);
  4343. if (c === '\'' && outsideDouble) {
  4344. outsideSingle = !outsideSingle;
  4345. }
  4346. else if (c === '"' && outsideSingle) {
  4347. outsideDouble = !outsideDouble;
  4348. }
  4349. }
  4350. return outsideSingle && outsideDouble;
  4351. }
  4352. /**
  4353. * Sanitizes the given untrusted CSS style property value (i.e. not an entire object, just a single
  4354. * value) and returns a value that is safe to use in a browser environment.
  4355. * @param {?} value
  4356. * @return {?}
  4357. */
  4358. function sanitizeStyle(value) {
  4359. value = String(value).trim(); // Make sure it's actually a string.
  4360. if (!value)
  4361. return '';
  4362. // Single url(...) values are supported, but only for URLs that sanitize cleanly. See above for
  4363. // reasoning behind this.
  4364. var /** @type {?} */ urlMatch = value.match(URL_RE);
  4365. if ((urlMatch && sanitizeUrl(urlMatch[1]) === urlMatch[1]) ||
  4366. value.match(SAFE_STYLE_VALUE) && hasBalancedQuotes(value)) {
  4367. return value; // Safe style values.
  4368. }
  4369. if (_angular_core.isDevMode()) {
  4370. getDOM().log("WARNING: sanitizing unsafe style value " + value + " (see http://g.co/ng/security#xss).");
  4371. }
  4372. return 'unsafe';
  4373. }
  4374. /**
  4375. * @fileoverview added by tsickle
  4376. * @suppress {checkTypes} checked by tsc
  4377. */
  4378. /**
  4379. * @license
  4380. * Copyright Google Inc. All Rights Reserved.
  4381. *
  4382. * Use of this source code is governed by an MIT-style license that can be
  4383. * found in the LICENSE file at https://angular.io/license
  4384. */
  4385. /**
  4386. * Marker interface for a value that's safe to use in a particular context.
  4387. *
  4388. * \@stable
  4389. * @record
  4390. */
  4391. /**
  4392. * Marker interface for a value that's safe to use as HTML.
  4393. *
  4394. * \@stable
  4395. * @record
  4396. */
  4397. /**
  4398. * Marker interface for a value that's safe to use as style (CSS).
  4399. *
  4400. * \@stable
  4401. * @record
  4402. */
  4403. /**
  4404. * Marker interface for a value that's safe to use as JavaScript.
  4405. *
  4406. * \@stable
  4407. * @record
  4408. */
  4409. /**
  4410. * Marker interface for a value that's safe to use as a URL linking to a document.
  4411. *
  4412. * \@stable
  4413. * @record
  4414. */
  4415. /**
  4416. * Marker interface for a value that's safe to use as a URL to load executable code from.
  4417. *
  4418. * \@stable
  4419. * @record
  4420. */
  4421. /**
  4422. * DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing
  4423. * values to be safe to use in the different DOM contexts.
  4424. *
  4425. * For example, when binding a URL in an `<a [href]="someValue">` hyperlink, `someValue` will be
  4426. * sanitized so that an attacker cannot inject e.g. a `javascript:` URL that would execute code on
  4427. * the website.
  4428. *
  4429. * In specific situations, it might be necessary to disable sanitization, for example if the
  4430. * application genuinely needs to produce a `javascript:` style link with a dynamic value in it.
  4431. * Users can bypass security by constructing a value with one of the `bypassSecurityTrust...`
  4432. * methods, and then binding to that value from the template.
  4433. *
  4434. * These situations should be very rare, and extraordinary care must be taken to avoid creating a
  4435. * Cross Site Scripting (XSS) security bug!
  4436. *
  4437. * When using `bypassSecurityTrust...`, make sure to call the method as early as possible and as
  4438. * close as possible to the source of the value, to make it easy to verify no security bug is
  4439. * created by its use.
  4440. *
  4441. * It is not required (and not recommended) to bypass security if the value is safe, e.g. a URL that
  4442. * does not start with a suspicious protocol, or an HTML snippet that does not contain dangerous
  4443. * code. The sanitizer leaves safe values intact.
  4444. *
  4445. * \@security Calling any of the `bypassSecurityTrust...` APIs disables Angular's built-in
  4446. * sanitization for the value passed in. Carefully check and audit all values and code paths going
  4447. * into this call. Make sure any user data is appropriately escaped for this security context.
  4448. * For more detail, see the [Security Guide](http://g.co/ng/security).
  4449. *
  4450. * \@stable
  4451. * @abstract
  4452. */
  4453. var DomSanitizer = /** @class */ (function () {
  4454. function DomSanitizer() {
  4455. }
  4456. return DomSanitizer;
  4457. }());
  4458. var DomSanitizerImpl = /** @class */ (function (_super) {
  4459. __extends(DomSanitizerImpl, _super);
  4460. function DomSanitizerImpl(_doc) {
  4461. var _this = _super.call(this) || this;
  4462. _this._doc = _doc;
  4463. return _this;
  4464. }
  4465. /**
  4466. * @param {?} ctx
  4467. * @param {?} value
  4468. * @return {?}
  4469. */
  4470. DomSanitizerImpl.prototype.sanitize = /**
  4471. * @param {?} ctx
  4472. * @param {?} value
  4473. * @return {?}
  4474. */
  4475. function (ctx, value) {
  4476. if (value == null)
  4477. return null;
  4478. switch (ctx) {
  4479. case _angular_core.SecurityContext.NONE:
  4480. return /** @type {?} */ (value);
  4481. case _angular_core.SecurityContext.HTML:
  4482. if (value instanceof SafeHtmlImpl)
  4483. return value.changingThisBreaksApplicationSecurity;
  4484. this.checkNotSafeValue(value, 'HTML');
  4485. return sanitizeHtml(this._doc, String(value));
  4486. case _angular_core.SecurityContext.STYLE:
  4487. if (value instanceof SafeStyleImpl)
  4488. return value.changingThisBreaksApplicationSecurity;
  4489. this.checkNotSafeValue(value, 'Style');
  4490. return sanitizeStyle(/** @type {?} */ (value));
  4491. case _angular_core.SecurityContext.SCRIPT:
  4492. if (value instanceof SafeScriptImpl)
  4493. return value.changingThisBreaksApplicationSecurity;
  4494. this.checkNotSafeValue(value, 'Script');
  4495. throw new Error('unsafe value used in a script context');
  4496. case _angular_core.SecurityContext.URL:
  4497. if (value instanceof SafeResourceUrlImpl || value instanceof SafeUrlImpl) {
  4498. // Allow resource URLs in URL contexts, they are strictly more trusted.
  4499. return value.changingThisBreaksApplicationSecurity;
  4500. }
  4501. this.checkNotSafeValue(value, 'URL');
  4502. return sanitizeUrl(String(value));
  4503. case _angular_core.SecurityContext.RESOURCE_URL:
  4504. if (value instanceof SafeResourceUrlImpl) {
  4505. return value.changingThisBreaksApplicationSecurity;
  4506. }
  4507. this.checkNotSafeValue(value, 'ResourceURL');
  4508. throw new Error('unsafe value used in a resource URL context (see http://g.co/ng/security#xss)');
  4509. default:
  4510. throw new Error("Unexpected SecurityContext " + ctx + " (see http://g.co/ng/security#xss)");
  4511. }
  4512. };
  4513. /**
  4514. * @param {?} value
  4515. * @param {?} expectedType
  4516. * @return {?}
  4517. */
  4518. DomSanitizerImpl.prototype.checkNotSafeValue = /**
  4519. * @param {?} value
  4520. * @param {?} expectedType
  4521. * @return {?}
  4522. */
  4523. function (value, expectedType) {
  4524. if (value instanceof SafeValueImpl) {
  4525. throw new Error("Required a safe " + expectedType + ", got a " + value.getTypeName() + " " +
  4526. "(see http://g.co/ng/security#xss)");
  4527. }
  4528. };
  4529. /**
  4530. * @param {?} value
  4531. * @return {?}
  4532. */
  4533. DomSanitizerImpl.prototype.bypassSecurityTrustHtml = /**
  4534. * @param {?} value
  4535. * @return {?}
  4536. */
  4537. function (value) { return new SafeHtmlImpl(value); };
  4538. /**
  4539. * @param {?} value
  4540. * @return {?}
  4541. */
  4542. DomSanitizerImpl.prototype.bypassSecurityTrustStyle = /**
  4543. * @param {?} value
  4544. * @return {?}
  4545. */
  4546. function (value) { return new SafeStyleImpl(value); };
  4547. /**
  4548. * @param {?} value
  4549. * @return {?}
  4550. */
  4551. DomSanitizerImpl.prototype.bypassSecurityTrustScript = /**
  4552. * @param {?} value
  4553. * @return {?}
  4554. */
  4555. function (value) { return new SafeScriptImpl(value); };
  4556. /**
  4557. * @param {?} value
  4558. * @return {?}
  4559. */
  4560. DomSanitizerImpl.prototype.bypassSecurityTrustUrl = /**
  4561. * @param {?} value
  4562. * @return {?}
  4563. */
  4564. function (value) { return new SafeUrlImpl(value); };
  4565. /**
  4566. * @param {?} value
  4567. * @return {?}
  4568. */
  4569. DomSanitizerImpl.prototype.bypassSecurityTrustResourceUrl = /**
  4570. * @param {?} value
  4571. * @return {?}
  4572. */
  4573. function (value) {
  4574. return new SafeResourceUrlImpl(value);
  4575. };
  4576. DomSanitizerImpl.decorators = [
  4577. { type: _angular_core.Injectable },
  4578. ];
  4579. /** @nocollapse */
  4580. DomSanitizerImpl.ctorParameters = function () { return [
  4581. { type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1,] },] },
  4582. ]; };
  4583. return DomSanitizerImpl;
  4584. }(DomSanitizer));
  4585. /**
  4586. * @abstract
  4587. */
  4588. var SafeValueImpl = /** @class */ (function () {
  4589. function SafeValueImpl(changingThisBreaksApplicationSecurity) {
  4590. // empty
  4591. this.changingThisBreaksApplicationSecurity = changingThisBreaksApplicationSecurity;
  4592. }
  4593. /**
  4594. * @return {?}
  4595. */
  4596. SafeValueImpl.prototype.toString = /**
  4597. * @return {?}
  4598. */
  4599. function () {
  4600. return "SafeValue must use [property]=binding: " + this.changingThisBreaksApplicationSecurity +
  4601. " (see http://g.co/ng/security#xss)";
  4602. };
  4603. return SafeValueImpl;
  4604. }());
  4605. var SafeHtmlImpl = /** @class */ (function (_super) {
  4606. __extends(SafeHtmlImpl, _super);
  4607. function SafeHtmlImpl() {
  4608. return _super !== null && _super.apply(this, arguments) || this;
  4609. }
  4610. /**
  4611. * @return {?}
  4612. */
  4613. SafeHtmlImpl.prototype.getTypeName = /**
  4614. * @return {?}
  4615. */
  4616. function () { return 'HTML'; };
  4617. return SafeHtmlImpl;
  4618. }(SafeValueImpl));
  4619. var SafeStyleImpl = /** @class */ (function (_super) {
  4620. __extends(SafeStyleImpl, _super);
  4621. function SafeStyleImpl() {
  4622. return _super !== null && _super.apply(this, arguments) || this;
  4623. }
  4624. /**
  4625. * @return {?}
  4626. */
  4627. SafeStyleImpl.prototype.getTypeName = /**
  4628. * @return {?}
  4629. */
  4630. function () { return 'Style'; };
  4631. return SafeStyleImpl;
  4632. }(SafeValueImpl));
  4633. var SafeScriptImpl = /** @class */ (function (_super) {
  4634. __extends(SafeScriptImpl, _super);
  4635. function SafeScriptImpl() {
  4636. return _super !== null && _super.apply(this, arguments) || this;
  4637. }
  4638. /**
  4639. * @return {?}
  4640. */
  4641. SafeScriptImpl.prototype.getTypeName = /**
  4642. * @return {?}
  4643. */
  4644. function () { return 'Script'; };
  4645. return SafeScriptImpl;
  4646. }(SafeValueImpl));
  4647. var SafeUrlImpl = /** @class */ (function (_super) {
  4648. __extends(SafeUrlImpl, _super);
  4649. function SafeUrlImpl() {
  4650. return _super !== null && _super.apply(this, arguments) || this;
  4651. }
  4652. /**
  4653. * @return {?}
  4654. */
  4655. SafeUrlImpl.prototype.getTypeName = /**
  4656. * @return {?}
  4657. */
  4658. function () { return 'URL'; };
  4659. return SafeUrlImpl;
  4660. }(SafeValueImpl));
  4661. var SafeResourceUrlImpl = /** @class */ (function (_super) {
  4662. __extends(SafeResourceUrlImpl, _super);
  4663. function SafeResourceUrlImpl() {
  4664. return _super !== null && _super.apply(this, arguments) || this;
  4665. }
  4666. /**
  4667. * @return {?}
  4668. */
  4669. SafeResourceUrlImpl.prototype.getTypeName = /**
  4670. * @return {?}
  4671. */
  4672. function () { return 'ResourceURL'; };
  4673. return SafeResourceUrlImpl;
  4674. }(SafeValueImpl));
  4675. /**
  4676. * @fileoverview added by tsickle
  4677. * @suppress {checkTypes} checked by tsc
  4678. */
  4679. /**
  4680. * @license
  4681. * Copyright Google Inc. All Rights Reserved.
  4682. *
  4683. * Use of this source code is governed by an MIT-style license that can be
  4684. * found in the LICENSE file at https://angular.io/license
  4685. */
  4686. var INTERNAL_BROWSER_PLATFORM_PROVIDERS = [
  4687. { provide: _angular_core.PLATFORM_ID, useValue: _angular_common.ɵPLATFORM_BROWSER_ID },
  4688. { provide: _angular_core.PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true },
  4689. { provide: _angular_common.PlatformLocation, useClass: BrowserPlatformLocation, deps: [DOCUMENT$1] },
  4690. { provide: DOCUMENT$1, useFactory: _document, deps: [] },
  4691. ];
  4692. /**
  4693. * \@security Replacing built-in sanitization providers exposes the application to XSS risks.
  4694. * Attacker-controlled data introduced by an unsanitized provider could expose your
  4695. * application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
  4696. * \@experimental
  4697. */
  4698. var BROWSER_SANITIZATION_PROVIDERS = [
  4699. { provide: _angular_core.Sanitizer, useExisting: DomSanitizer },
  4700. { provide: DomSanitizer, useClass: DomSanitizerImpl, deps: [DOCUMENT$1] },
  4701. ];
  4702. /**
  4703. * \@stable
  4704. */
  4705. var platformBrowser = _angular_core.createPlatformFactory(_angular_core.platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
  4706. /**
  4707. * @return {?}
  4708. */
  4709. function initDomAdapter() {
  4710. BrowserDomAdapter.makeCurrent();
  4711. BrowserGetTestability.init();
  4712. }
  4713. /**
  4714. * @return {?}
  4715. */
  4716. function errorHandler() {
  4717. return new _angular_core.ErrorHandler();
  4718. }
  4719. /**
  4720. * @return {?}
  4721. */
  4722. function _document() {
  4723. return document;
  4724. }
  4725. /**
  4726. * The ng module for the browser.
  4727. *
  4728. * \@stable
  4729. */
  4730. var BrowserModule = /** @class */ (function () {
  4731. function BrowserModule(parentModule) {
  4732. if (parentModule) {
  4733. throw new Error("BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.");
  4734. }
  4735. }
  4736. /**
  4737. * Configures a browser-based application to transition from a server-rendered app, if
  4738. * one is present on the page. The specified parameters must include an application id,
  4739. * which must match between the client and server applications.
  4740. *
  4741. * @experimental
  4742. */
  4743. /**
  4744. * Configures a browser-based application to transition from a server-rendered app, if
  4745. * one is present on the page. The specified parameters must include an application id,
  4746. * which must match between the client and server applications.
  4747. *
  4748. * \@experimental
  4749. * @param {?} params
  4750. * @return {?}
  4751. */
  4752. BrowserModule.withServerTransition = /**
  4753. * Configures a browser-based application to transition from a server-rendered app, if
  4754. * one is present on the page. The specified parameters must include an application id,
  4755. * which must match between the client and server applications.
  4756. *
  4757. * \@experimental
  4758. * @param {?} params
  4759. * @return {?}
  4760. */
  4761. function (params) {
  4762. return {
  4763. ngModule: BrowserModule,
  4764. providers: [
  4765. { provide: _angular_core.APP_ID, useValue: params.appId },
  4766. { provide: TRANSITION_ID, useExisting: _angular_core.APP_ID },
  4767. SERVER_TRANSITION_PROVIDERS,
  4768. ],
  4769. };
  4770. };
  4771. BrowserModule.decorators = [
  4772. { type: _angular_core.NgModule, args: [{
  4773. providers: [
  4774. BROWSER_SANITIZATION_PROVIDERS,
  4775. { provide: _angular_core.ErrorHandler, useFactory: errorHandler, deps: [] },
  4776. { provide: EVENT_MANAGER_PLUGINS, useClass: DomEventsPlugin, multi: true },
  4777. { provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true },
  4778. { provide: EVENT_MANAGER_PLUGINS, useClass: HammerGesturesPlugin, multi: true },
  4779. { provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig },
  4780. DomRendererFactory2,
  4781. { provide: _angular_core.RendererFactory2, useExisting: DomRendererFactory2 },
  4782. { provide: SharedStylesHost, useExisting: DomSharedStylesHost },
  4783. DomSharedStylesHost,
  4784. _angular_core.Testability,
  4785. EventManager,
  4786. ELEMENT_PROBE_PROVIDERS,
  4787. Meta,
  4788. Title,
  4789. ],
  4790. exports: [_angular_common.CommonModule, _angular_core.ApplicationModule]
  4791. },] },
  4792. ];
  4793. /** @nocollapse */
  4794. BrowserModule.ctorParameters = function () { return [
  4795. { type: BrowserModule, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.SkipSelf },] },
  4796. ]; };
  4797. return BrowserModule;
  4798. }());
  4799. /**
  4800. * @fileoverview added by tsickle
  4801. * @suppress {checkTypes} checked by tsc
  4802. */
  4803. /**
  4804. * @license
  4805. * Copyright Google Inc. All Rights Reserved.
  4806. *
  4807. * Use of this source code is governed by an MIT-style license that can be
  4808. * found in the LICENSE file at https://angular.io/license
  4809. */
  4810. var win = typeof window !== 'undefined' && window || /** @type {?} */ ({});
  4811. /**
  4812. * @fileoverview added by tsickle
  4813. * @suppress {checkTypes} checked by tsc
  4814. */
  4815. /**
  4816. * @license
  4817. * Copyright Google Inc. All Rights Reserved.
  4818. *
  4819. * Use of this source code is governed by an MIT-style license that can be
  4820. * found in the LICENSE file at https://angular.io/license
  4821. */
  4822. var ChangeDetectionPerfRecord = /** @class */ (function () {
  4823. function ChangeDetectionPerfRecord(msPerTick, numTicks) {
  4824. this.msPerTick = msPerTick;
  4825. this.numTicks = numTicks;
  4826. }
  4827. return ChangeDetectionPerfRecord;
  4828. }());
  4829. /**
  4830. * Entry point for all Angular profiling-related debug tools. This object
  4831. * corresponds to the `ng.profiler` in the dev console.
  4832. */
  4833. var AngularProfiler = /** @class */ (function () {
  4834. function AngularProfiler(ref) {
  4835. this.appRef = ref.injector.get(_angular_core.ApplicationRef);
  4836. }
  4837. // tslint:disable:no-console
  4838. /**
  4839. * Exercises change detection in a loop and then prints the average amount of
  4840. * time in milliseconds how long a single round of change detection takes for
  4841. * the current state of the UI. It runs a minimum of 5 rounds for a minimum
  4842. * of 500 milliseconds.
  4843. *
  4844. * Optionally, a user may pass a `config` parameter containing a map of
  4845. * options. Supported options are:
  4846. *
  4847. * `record` (boolean) - causes the profiler to record a CPU profile while
  4848. * it exercises the change detector. Example:
  4849. *
  4850. * ```
  4851. * ng.profiler.timeChangeDetection({record: true})
  4852. * ```
  4853. */
  4854. /**
  4855. * Exercises change detection in a loop and then prints the average amount of
  4856. * time in milliseconds how long a single round of change detection takes for
  4857. * the current state of the UI. It runs a minimum of 5 rounds for a minimum
  4858. * of 500 milliseconds.
  4859. *
  4860. * Optionally, a user may pass a `config` parameter containing a map of
  4861. * options. Supported options are:
  4862. *
  4863. * `record` (boolean) - causes the profiler to record a CPU profile while
  4864. * it exercises the change detector. Example:
  4865. *
  4866. * ```
  4867. * ng.profiler.timeChangeDetection({record: true})
  4868. * ```
  4869. * @param {?} config
  4870. * @return {?}
  4871. */
  4872. AngularProfiler.prototype.timeChangeDetection = /**
  4873. * Exercises change detection in a loop and then prints the average amount of
  4874. * time in milliseconds how long a single round of change detection takes for
  4875. * the current state of the UI. It runs a minimum of 5 rounds for a minimum
  4876. * of 500 milliseconds.
  4877. *
  4878. * Optionally, a user may pass a `config` parameter containing a map of
  4879. * options. Supported options are:
  4880. *
  4881. * `record` (boolean) - causes the profiler to record a CPU profile while
  4882. * it exercises the change detector. Example:
  4883. *
  4884. * ```
  4885. * ng.profiler.timeChangeDetection({record: true})
  4886. * ```
  4887. * @param {?} config
  4888. * @return {?}
  4889. */
  4890. function (config) {
  4891. var /** @type {?} */ record = config && config['record'];
  4892. var /** @type {?} */ profileName = 'Change Detection';
  4893. // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened
  4894. var /** @type {?} */ isProfilerAvailable = win.console.profile != null;
  4895. if (record && isProfilerAvailable) {
  4896. win.console.profile(profileName);
  4897. }
  4898. var /** @type {?} */ start = getDOM().performanceNow();
  4899. var /** @type {?} */ numTicks = 0;
  4900. while (numTicks < 5 || (getDOM().performanceNow() - start) < 500) {
  4901. this.appRef.tick();
  4902. numTicks++;
  4903. }
  4904. var /** @type {?} */ end = getDOM().performanceNow();
  4905. if (record && isProfilerAvailable) {
  4906. // need to cast to <any> because type checker thinks there's no argument
  4907. // while in fact there is:
  4908. //
  4909. // https://developer.mozilla.org/en-US/docs/Web/API/Console/profileEnd
  4910. (/** @type {?} */ (win.console.profileEnd))(profileName);
  4911. }
  4912. var /** @type {?} */ msPerTick = (end - start) / numTicks;
  4913. win.console.log("ran " + numTicks + " change detection cycles");
  4914. win.console.log(msPerTick.toFixed(2) + " ms per check");
  4915. return new ChangeDetectionPerfRecord(msPerTick, numTicks);
  4916. };
  4917. return AngularProfiler;
  4918. }());
  4919. /**
  4920. * @fileoverview added by tsickle
  4921. * @suppress {checkTypes} checked by tsc
  4922. */
  4923. /**
  4924. * @license
  4925. * Copyright Google Inc. All Rights Reserved.
  4926. *
  4927. * Use of this source code is governed by an MIT-style license that can be
  4928. * found in the LICENSE file at https://angular.io/license
  4929. */
  4930. var PROFILER_GLOBAL_NAME = 'profiler';
  4931. /**
  4932. * Enabled Angular debug tools that are accessible via your browser's
  4933. * developer console.
  4934. *
  4935. * Usage:
  4936. *
  4937. * 1. Open developer console (e.g. in Chrome Ctrl + Shift + j)
  4938. * 1. Type `ng.` (usually the console will show auto-complete suggestion)
  4939. * 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
  4940. * then hit Enter.
  4941. *
  4942. * \@experimental All debugging apis are currently experimental.
  4943. * @template T
  4944. * @param {?} ref
  4945. * @return {?}
  4946. */
  4947. function enableDebugTools(ref) {
  4948. exportNgVar(PROFILER_GLOBAL_NAME, new AngularProfiler(ref));
  4949. return ref;
  4950. }
  4951. /**
  4952. * Disables Angular tools.
  4953. *
  4954. * \@experimental All debugging apis are currently experimental.
  4955. * @return {?}
  4956. */
  4957. function disableDebugTools() {
  4958. exportNgVar(PROFILER_GLOBAL_NAME, null);
  4959. }
  4960. /**
  4961. * @fileoverview added by tsickle
  4962. * @suppress {checkTypes} checked by tsc
  4963. */
  4964. /**
  4965. * @license
  4966. * Copyright Google Inc. All Rights Reserved.
  4967. *
  4968. * Use of this source code is governed by an MIT-style license that can be
  4969. * found in the LICENSE file at https://angular.io/license
  4970. */
  4971. /**
  4972. * @param {?} text
  4973. * @return {?}
  4974. */
  4975. function escapeHtml(text) {
  4976. var /** @type {?} */ escapedText = {
  4977. '&': '&a;',
  4978. '"': '&q;',
  4979. '\'': '&s;',
  4980. '<': '&l;',
  4981. '>': '&g;',
  4982. };
  4983. return text.replace(/[&"'<>]/g, function (s) { return escapedText[s]; });
  4984. }
  4985. /**
  4986. * @param {?} text
  4987. * @return {?}
  4988. */
  4989. function unescapeHtml(text) {
  4990. var /** @type {?} */ unescapedText = {
  4991. '&a;': '&',
  4992. '&q;': '"',
  4993. '&s;': '\'',
  4994. '&l;': '<',
  4995. '&g;': '>',
  4996. };
  4997. return text.replace(/&[^;]+;/g, function (s) { return unescapedText[s]; });
  4998. }
  4999. /**
  5000. * Create a `StateKey<T>` that can be used to store value of type T with `TransferState`.
  5001. *
  5002. * Example:
  5003. *
  5004. * ```
  5005. * const COUNTER_KEY = makeStateKey<number>('counter');
  5006. * let value = 10;
  5007. *
  5008. * transferState.set(COUNTER_KEY, value);
  5009. * ```
  5010. *
  5011. * \@experimental
  5012. * @template T
  5013. * @param {?} key
  5014. * @return {?}
  5015. */
  5016. function makeStateKey(key) {
  5017. return /** @type {?} */ (key);
  5018. }
  5019. /**
  5020. * A key value store that is transferred from the application on the server side to the application
  5021. * on the client side.
  5022. *
  5023. * `TransferState` will be available as an injectable token. To use it import
  5024. * `ServerTransferStateModule` on the server and `BrowserTransferStateModule` on the client.
  5025. *
  5026. * The values in the store are serialized/deserialized using JSON.stringify/JSON.parse. So only
  5027. * boolean, number, string, null and non-class objects will be serialized and deserialzied in a
  5028. * non-lossy manner.
  5029. *
  5030. * \@experimental
  5031. */
  5032. var TransferState = /** @class */ (function () {
  5033. function TransferState() {
  5034. this.store = {};
  5035. this.onSerializeCallbacks = {};
  5036. }
  5037. /** @internal */
  5038. /**
  5039. * \@internal
  5040. * @param {?} initState
  5041. * @return {?}
  5042. */
  5043. TransferState.init = /**
  5044. * \@internal
  5045. * @param {?} initState
  5046. * @return {?}
  5047. */
  5048. function (initState) {
  5049. var /** @type {?} */ transferState = new TransferState();
  5050. transferState.store = initState;
  5051. return transferState;
  5052. };
  5053. /**
  5054. * Get the value corresponding to a key. Return `defaultValue` if key is not found.
  5055. */
  5056. /**
  5057. * Get the value corresponding to a key. Return `defaultValue` if key is not found.
  5058. * @template T
  5059. * @param {?} key
  5060. * @param {?} defaultValue
  5061. * @return {?}
  5062. */
  5063. TransferState.prototype.get = /**
  5064. * Get the value corresponding to a key. Return `defaultValue` if key is not found.
  5065. * @template T
  5066. * @param {?} key
  5067. * @param {?} defaultValue
  5068. * @return {?}
  5069. */
  5070. function (key, defaultValue) {
  5071. return this.store[key] !== undefined ? /** @type {?} */ (this.store[key]) : defaultValue;
  5072. };
  5073. /**
  5074. * Set the value corresponding to a key.
  5075. */
  5076. /**
  5077. * Set the value corresponding to a key.
  5078. * @template T
  5079. * @param {?} key
  5080. * @param {?} value
  5081. * @return {?}
  5082. */
  5083. TransferState.prototype.set = /**
  5084. * Set the value corresponding to a key.
  5085. * @template T
  5086. * @param {?} key
  5087. * @param {?} value
  5088. * @return {?}
  5089. */
  5090. function (key, value) { this.store[key] = value; };
  5091. /**
  5092. * Remove a key from the store.
  5093. */
  5094. /**
  5095. * Remove a key from the store.
  5096. * @template T
  5097. * @param {?} key
  5098. * @return {?}
  5099. */
  5100. TransferState.prototype.remove = /**
  5101. * Remove a key from the store.
  5102. * @template T
  5103. * @param {?} key
  5104. * @return {?}
  5105. */
  5106. function (key) { delete this.store[key]; };
  5107. /**
  5108. * Test whether a key exists in the store.
  5109. */
  5110. /**
  5111. * Test whether a key exists in the store.
  5112. * @template T
  5113. * @param {?} key
  5114. * @return {?}
  5115. */
  5116. TransferState.prototype.hasKey = /**
  5117. * Test whether a key exists in the store.
  5118. * @template T
  5119. * @param {?} key
  5120. * @return {?}
  5121. */
  5122. function (key) { return this.store.hasOwnProperty(key); };
  5123. /**
  5124. * Register a callback to provide the value for a key when `toJson` is called.
  5125. */
  5126. /**
  5127. * Register a callback to provide the value for a key when `toJson` is called.
  5128. * @template T
  5129. * @param {?} key
  5130. * @param {?} callback
  5131. * @return {?}
  5132. */
  5133. TransferState.prototype.onSerialize = /**
  5134. * Register a callback to provide the value for a key when `toJson` is called.
  5135. * @template T
  5136. * @param {?} key
  5137. * @param {?} callback
  5138. * @return {?}
  5139. */
  5140. function (key, callback) {
  5141. this.onSerializeCallbacks[key] = callback;
  5142. };
  5143. /**
  5144. * Serialize the current state of the store to JSON.
  5145. */
  5146. /**
  5147. * Serialize the current state of the store to JSON.
  5148. * @return {?}
  5149. */
  5150. TransferState.prototype.toJson = /**
  5151. * Serialize the current state of the store to JSON.
  5152. * @return {?}
  5153. */
  5154. function () {
  5155. // Call the onSerialize callbacks and put those values into the store.
  5156. for (var /** @type {?} */ key in this.onSerializeCallbacks) {
  5157. if (this.onSerializeCallbacks.hasOwnProperty(key)) {
  5158. try {
  5159. this.store[key] = this.onSerializeCallbacks[key]();
  5160. }
  5161. catch (/** @type {?} */ e) {
  5162. console.warn('Exception in onSerialize callback: ', e);
  5163. }
  5164. }
  5165. }
  5166. return JSON.stringify(this.store);
  5167. };
  5168. TransferState.decorators = [
  5169. { type: _angular_core.Injectable },
  5170. ];
  5171. /** @nocollapse */
  5172. TransferState.ctorParameters = function () { return []; };
  5173. return TransferState;
  5174. }());
  5175. /**
  5176. * @param {?} doc
  5177. * @param {?} appId
  5178. * @return {?}
  5179. */
  5180. function initTransferState(doc, appId) {
  5181. // Locate the script tag with the JSON data transferred from the server.
  5182. // The id of the script tag is set to the Angular appId + 'state'.
  5183. var /** @type {?} */ script = doc.getElementById(appId + '-state');
  5184. var /** @type {?} */ initialState = {};
  5185. if (script && script.textContent) {
  5186. try {
  5187. initialState = JSON.parse(unescapeHtml(script.textContent));
  5188. }
  5189. catch (/** @type {?} */ e) {
  5190. console.warn('Exception while restoring TransferState for app ' + appId, e);
  5191. }
  5192. }
  5193. return TransferState.init(initialState);
  5194. }
  5195. /**
  5196. * NgModule to install on the client side while using the `TransferState` to transfer state from
  5197. * server to client.
  5198. *
  5199. * \@experimental
  5200. */
  5201. var BrowserTransferStateModule = /** @class */ (function () {
  5202. function BrowserTransferStateModule() {
  5203. }
  5204. BrowserTransferStateModule.decorators = [
  5205. { type: _angular_core.NgModule, args: [{
  5206. providers: [{ provide: TransferState, useFactory: initTransferState, deps: [DOCUMENT$1, _angular_core.APP_ID] }],
  5207. },] },
  5208. ];
  5209. /** @nocollapse */
  5210. BrowserTransferStateModule.ctorParameters = function () { return []; };
  5211. return BrowserTransferStateModule;
  5212. }());
  5213. /**
  5214. * @fileoverview added by tsickle
  5215. * @suppress {checkTypes} checked by tsc
  5216. */
  5217. /**
  5218. * @license
  5219. * Copyright Google Inc. All Rights Reserved.
  5220. *
  5221. * Use of this source code is governed by an MIT-style license that can be
  5222. * found in the LICENSE file at https://angular.io/license
  5223. */
  5224. /**
  5225. * Predicates for use with {\@link DebugElement}'s query functions.
  5226. *
  5227. * \@experimental All debugging apis are currently experimental.
  5228. */
  5229. var By = /** @class */ (function () {
  5230. function By() {
  5231. }
  5232. /**
  5233. * Match all elements.
  5234. *
  5235. * ## Example
  5236. *
  5237. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
  5238. */
  5239. /**
  5240. * Match all elements.
  5241. *
  5242. * ## Example
  5243. *
  5244. * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
  5245. * @return {?}
  5246. */
  5247. By.all = /**
  5248. * Match all elements.
  5249. *
  5250. * ## Example
  5251. *
  5252. * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
  5253. * @return {?}
  5254. */
  5255. function () { return function (debugElement) { return true; }; };
  5256. /**
  5257. * Match elements by the given CSS selector.
  5258. *
  5259. * ## Example
  5260. *
  5261. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
  5262. */
  5263. /**
  5264. * Match elements by the given CSS selector.
  5265. *
  5266. * ## Example
  5267. *
  5268. * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
  5269. * @param {?} selector
  5270. * @return {?}
  5271. */
  5272. By.css = /**
  5273. * Match elements by the given CSS selector.
  5274. *
  5275. * ## Example
  5276. *
  5277. * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
  5278. * @param {?} selector
  5279. * @return {?}
  5280. */
  5281. function (selector) {
  5282. return function (debugElement) {
  5283. return debugElement.nativeElement != null ?
  5284. getDOM().elementMatches(debugElement.nativeElement, selector) :
  5285. false;
  5286. };
  5287. };
  5288. /**
  5289. * Match elements that have the given directive present.
  5290. *
  5291. * ## Example
  5292. *
  5293. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
  5294. */
  5295. /**
  5296. * Match elements that have the given directive present.
  5297. *
  5298. * ## Example
  5299. *
  5300. * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
  5301. * @param {?} type
  5302. * @return {?}
  5303. */
  5304. By.directive = /**
  5305. * Match elements that have the given directive present.
  5306. *
  5307. * ## Example
  5308. *
  5309. * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
  5310. * @param {?} type
  5311. * @return {?}
  5312. */
  5313. function (type) {
  5314. return function (debugElement) { return ((debugElement.providerTokens)).indexOf(type) !== -1; };
  5315. };
  5316. return By;
  5317. }());
  5318. /**
  5319. * @fileoverview added by tsickle
  5320. * @suppress {checkTypes} checked by tsc
  5321. */
  5322. /**
  5323. * @license
  5324. * Copyright Google Inc. All Rights Reserved.
  5325. *
  5326. * Use of this source code is governed by an MIT-style license that can be
  5327. * found in the LICENSE file at https://angular.io/license
  5328. */
  5329. /**
  5330. * @fileoverview added by tsickle
  5331. * @suppress {checkTypes} checked by tsc
  5332. */
  5333. /**
  5334. * @license
  5335. * Copyright Google Inc. All Rights Reserved.
  5336. *
  5337. * Use of this source code is governed by an MIT-style license that can be
  5338. * found in the LICENSE file at https://angular.io/license
  5339. */
  5340. /**
  5341. * \@stable
  5342. */
  5343. var VERSION = new _angular_core.Version('5.2.11');
  5344. exports.BrowserModule = BrowserModule;
  5345. exports.platformBrowser = platformBrowser;
  5346. exports.Meta = Meta;
  5347. exports.Title = Title;
  5348. exports.disableDebugTools = disableDebugTools;
  5349. exports.enableDebugTools = enableDebugTools;
  5350. exports.BrowserTransferStateModule = BrowserTransferStateModule;
  5351. exports.TransferState = TransferState;
  5352. exports.makeStateKey = makeStateKey;
  5353. exports.By = By;
  5354. exports.DOCUMENT = DOCUMENT$1;
  5355. exports.EVENT_MANAGER_PLUGINS = EVENT_MANAGER_PLUGINS;
  5356. exports.EventManager = EventManager;
  5357. exports.HAMMER_GESTURE_CONFIG = HAMMER_GESTURE_CONFIG;
  5358. exports.HammerGestureConfig = HammerGestureConfig;
  5359. exports.DomSanitizer = DomSanitizer;
  5360. exports.VERSION = VERSION;
  5361. exports.ɵBROWSER_SANITIZATION_PROVIDERS = BROWSER_SANITIZATION_PROVIDERS;
  5362. exports.ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS = INTERNAL_BROWSER_PLATFORM_PROVIDERS;
  5363. exports.ɵinitDomAdapter = initDomAdapter;
  5364. exports.ɵBrowserDomAdapter = BrowserDomAdapter;
  5365. exports.ɵBrowserPlatformLocation = BrowserPlatformLocation;
  5366. exports.ɵTRANSITION_ID = TRANSITION_ID;
  5367. exports.ɵBrowserGetTestability = BrowserGetTestability;
  5368. exports.ɵescapeHtml = escapeHtml;
  5369. exports.ɵELEMENT_PROBE_PROVIDERS = ELEMENT_PROBE_PROVIDERS;
  5370. exports.ɵDomAdapter = DomAdapter;
  5371. exports.ɵgetDOM = getDOM;
  5372. exports.ɵsetRootDomAdapter = setRootDomAdapter;
  5373. exports.ɵDomRendererFactory2 = DomRendererFactory2;
  5374. exports.ɵNAMESPACE_URIS = NAMESPACE_URIS;
  5375. exports.ɵflattenStyles = flattenStyles;
  5376. exports.ɵshimContentAttribute = shimContentAttribute;
  5377. exports.ɵshimHostAttribute = shimHostAttribute;
  5378. exports.ɵDomEventsPlugin = DomEventsPlugin;
  5379. exports.ɵHammerGesturesPlugin = HammerGesturesPlugin;
  5380. exports.ɵKeyEventsPlugin = KeyEventsPlugin;
  5381. exports.ɵDomSharedStylesHost = DomSharedStylesHost;
  5382. exports.ɵSharedStylesHost = SharedStylesHost;
  5383. exports.ɵb = _document;
  5384. exports.ɵa = errorHandler;
  5385. exports.ɵi = GenericBrowserDomAdapter;
  5386. exports.ɵg = SERVER_TRANSITION_PROVIDERS;
  5387. exports.ɵf = appInitializerFactory;
  5388. exports.ɵc = initTransferState;
  5389. exports.ɵh = _createNgProbe;
  5390. exports.ɵd = EventManagerPlugin;
  5391. exports.ɵe = DomSanitizerImpl;
  5392. Object.defineProperty(exports, '__esModule', { value: true });
  5393. })));
  5394. //# sourceMappingURL=platform-browser.umd.js.map