browser.js 200 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627
  1. /**
  2. * @license Angular v8.1.0
  3. * (c) 2010-2019 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import { __spread, __decorate, __read, __extends, __assign, __values } from 'tslib';
  7. import { NoopAnimationPlayer, ɵAnimationGroupPlayer, ɵPRE_STYLE, AUTO_STYLE, sequence, style } from '@angular/animations';
  8. import { Injectable } from '@angular/core';
  9. function isBrowser() {
  10. return (typeof window !== 'undefined' && typeof window.document !== 'undefined');
  11. }
  12. function isNode() {
  13. return (typeof process !== 'undefined');
  14. }
  15. function optimizeGroupPlayer(players) {
  16. switch (players.length) {
  17. case 0:
  18. return new NoopAnimationPlayer();
  19. case 1:
  20. return players[0];
  21. default:
  22. return new ɵAnimationGroupPlayer(players);
  23. }
  24. }
  25. function normalizeKeyframes(driver, normalizer, element, keyframes, preStyles, postStyles) {
  26. if (preStyles === void 0) { preStyles = {}; }
  27. if (postStyles === void 0) { postStyles = {}; }
  28. var errors = [];
  29. var normalizedKeyframes = [];
  30. var previousOffset = -1;
  31. var previousKeyframe = null;
  32. keyframes.forEach(function (kf) {
  33. var offset = kf['offset'];
  34. var isSameOffset = offset == previousOffset;
  35. var normalizedKeyframe = (isSameOffset && previousKeyframe) || {};
  36. Object.keys(kf).forEach(function (prop) {
  37. var normalizedProp = prop;
  38. var normalizedValue = kf[prop];
  39. if (prop !== 'offset') {
  40. normalizedProp = normalizer.normalizePropertyName(normalizedProp, errors);
  41. switch (normalizedValue) {
  42. case ɵPRE_STYLE:
  43. normalizedValue = preStyles[prop];
  44. break;
  45. case AUTO_STYLE:
  46. normalizedValue = postStyles[prop];
  47. break;
  48. default:
  49. normalizedValue =
  50. normalizer.normalizeStyleValue(prop, normalizedProp, normalizedValue, errors);
  51. break;
  52. }
  53. }
  54. normalizedKeyframe[normalizedProp] = normalizedValue;
  55. });
  56. if (!isSameOffset) {
  57. normalizedKeyframes.push(normalizedKeyframe);
  58. }
  59. previousKeyframe = normalizedKeyframe;
  60. previousOffset = offset;
  61. });
  62. if (errors.length) {
  63. var LINE_START = '\n - ';
  64. throw new Error("Unable to animate due to the following errors:" + LINE_START + errors.join(LINE_START));
  65. }
  66. return normalizedKeyframes;
  67. }
  68. function listenOnPlayer(player, eventName, event, callback) {
  69. switch (eventName) {
  70. case 'start':
  71. player.onStart(function () { return callback(event && copyAnimationEvent(event, 'start', player)); });
  72. break;
  73. case 'done':
  74. player.onDone(function () { return callback(event && copyAnimationEvent(event, 'done', player)); });
  75. break;
  76. case 'destroy':
  77. player.onDestroy(function () { return callback(event && copyAnimationEvent(event, 'destroy', player)); });
  78. break;
  79. }
  80. }
  81. function copyAnimationEvent(e, phaseName, player) {
  82. var totalTime = player.totalTime;
  83. var disabled = player.disabled ? true : false;
  84. var event = makeAnimationEvent(e.element, e.triggerName, e.fromState, e.toState, phaseName || e.phaseName, totalTime == undefined ? e.totalTime : totalTime, disabled);
  85. var data = e['_data'];
  86. if (data != null) {
  87. event['_data'] = data;
  88. }
  89. return event;
  90. }
  91. function makeAnimationEvent(element, triggerName, fromState, toState, phaseName, totalTime, disabled) {
  92. if (phaseName === void 0) { phaseName = ''; }
  93. if (totalTime === void 0) { totalTime = 0; }
  94. return { element: element, triggerName: triggerName, fromState: fromState, toState: toState, phaseName: phaseName, totalTime: totalTime, disabled: !!disabled };
  95. }
  96. function getOrSetAsInMap(map, key, defaultValue) {
  97. var value;
  98. if (map instanceof Map) {
  99. value = map.get(key);
  100. if (!value) {
  101. map.set(key, value = defaultValue);
  102. }
  103. }
  104. else {
  105. value = map[key];
  106. if (!value) {
  107. value = map[key] = defaultValue;
  108. }
  109. }
  110. return value;
  111. }
  112. function parseTimelineCommand(command) {
  113. var separatorPos = command.indexOf(':');
  114. var id = command.substring(1, separatorPos);
  115. var action = command.substr(separatorPos + 1);
  116. return [id, action];
  117. }
  118. var _contains = function (elm1, elm2) { return false; };
  119. var _matches = function (element, selector) {
  120. return false;
  121. };
  122. var _query = function (element, selector, multi) {
  123. return [];
  124. };
  125. // Define utility methods for browsers and platform-server(domino) where Element
  126. // and utility methods exist.
  127. var _isNode = isNode();
  128. if (_isNode || typeof Element !== 'undefined') {
  129. // this is well supported in all browsers
  130. _contains = function (elm1, elm2) { return elm1.contains(elm2); };
  131. _matches = (function () {
  132. if (_isNode || Element.prototype.matches) {
  133. return function (element, selector) { return element.matches(selector); };
  134. }
  135. else {
  136. var proto = Element.prototype;
  137. var fn_1 = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector ||
  138. proto.oMatchesSelector || proto.webkitMatchesSelector;
  139. if (fn_1) {
  140. return function (element, selector) { return fn_1.apply(element, [selector]); };
  141. }
  142. else {
  143. return _matches;
  144. }
  145. }
  146. })();
  147. _query = function (element, selector, multi) {
  148. var results = [];
  149. if (multi) {
  150. results.push.apply(results, __spread(element.querySelectorAll(selector)));
  151. }
  152. else {
  153. var elm = element.querySelector(selector);
  154. if (elm) {
  155. results.push(elm);
  156. }
  157. }
  158. return results;
  159. };
  160. }
  161. function containsVendorPrefix(prop) {
  162. // Webkit is the only real popular vendor prefix nowadays
  163. // cc: http://shouldiprefix.com/
  164. return prop.substring(1, 6) == 'ebkit'; // webkit or Webkit
  165. }
  166. var _CACHED_BODY = null;
  167. var _IS_WEBKIT = false;
  168. function validateStyleProperty(prop) {
  169. if (!_CACHED_BODY) {
  170. _CACHED_BODY = getBodyNode() || {};
  171. _IS_WEBKIT = _CACHED_BODY.style ? ('WebkitAppearance' in _CACHED_BODY.style) : false;
  172. }
  173. var result = true;
  174. if (_CACHED_BODY.style && !containsVendorPrefix(prop)) {
  175. result = prop in _CACHED_BODY.style;
  176. if (!result && _IS_WEBKIT) {
  177. var camelProp = 'Webkit' + prop.charAt(0).toUpperCase() + prop.substr(1);
  178. result = camelProp in _CACHED_BODY.style;
  179. }
  180. }
  181. return result;
  182. }
  183. function getBodyNode() {
  184. if (typeof document != 'undefined') {
  185. return document.body;
  186. }
  187. return null;
  188. }
  189. var matchesElement = _matches;
  190. var containsElement = _contains;
  191. var invokeQuery = _query;
  192. function hypenatePropsObject(object) {
  193. var newObj = {};
  194. Object.keys(object).forEach(function (prop) {
  195. var newProp = prop.replace(/([a-z])([A-Z])/g, '$1-$2');
  196. newObj[newProp] = object[prop];
  197. });
  198. return newObj;
  199. }
  200. /**
  201. * @publicApi
  202. */
  203. var NoopAnimationDriver = /** @class */ (function () {
  204. function NoopAnimationDriver() {
  205. }
  206. NoopAnimationDriver.prototype.validateStyleProperty = function (prop) { return validateStyleProperty(prop); };
  207. NoopAnimationDriver.prototype.matchesElement = function (element, selector) {
  208. return matchesElement(element, selector);
  209. };
  210. NoopAnimationDriver.prototype.containsElement = function (elm1, elm2) { return containsElement(elm1, elm2); };
  211. NoopAnimationDriver.prototype.query = function (element, selector, multi) {
  212. return invokeQuery(element, selector, multi);
  213. };
  214. NoopAnimationDriver.prototype.computeStyle = function (element, prop, defaultValue) {
  215. return defaultValue || '';
  216. };
  217. NoopAnimationDriver.prototype.animate = function (element, keyframes, duration, delay, easing, previousPlayers, scrubberAccessRequested) {
  218. if (previousPlayers === void 0) { previousPlayers = []; }
  219. return new NoopAnimationPlayer(duration, delay);
  220. };
  221. NoopAnimationDriver = __decorate([
  222. Injectable()
  223. ], NoopAnimationDriver);
  224. return NoopAnimationDriver;
  225. }());
  226. /**
  227. * @publicApi
  228. */
  229. var AnimationDriver = /** @class */ (function () {
  230. function AnimationDriver() {
  231. }
  232. AnimationDriver.NOOP = new NoopAnimationDriver();
  233. return AnimationDriver;
  234. }());
  235. /**
  236. * @license
  237. * Copyright Google Inc. All Rights Reserved.
  238. *
  239. * Use of this source code is governed by an MIT-style license that can be
  240. * found in the LICENSE file at https://angular.io/license
  241. */
  242. var ONE_SECOND = 1000;
  243. var SUBSTITUTION_EXPR_START = '{{';
  244. var SUBSTITUTION_EXPR_END = '}}';
  245. var ENTER_CLASSNAME = 'ng-enter';
  246. var LEAVE_CLASSNAME = 'ng-leave';
  247. var NG_TRIGGER_CLASSNAME = 'ng-trigger';
  248. var NG_TRIGGER_SELECTOR = '.ng-trigger';
  249. var NG_ANIMATING_CLASSNAME = 'ng-animating';
  250. var NG_ANIMATING_SELECTOR = '.ng-animating';
  251. function resolveTimingValue(value) {
  252. if (typeof value == 'number')
  253. return value;
  254. var matches = value.match(/^(-?[\.\d]+)(m?s)/);
  255. if (!matches || matches.length < 2)
  256. return 0;
  257. return _convertTimeValueToMS(parseFloat(matches[1]), matches[2]);
  258. }
  259. function _convertTimeValueToMS(value, unit) {
  260. switch (unit) {
  261. case 's':
  262. return value * ONE_SECOND;
  263. default: // ms or something else
  264. return value;
  265. }
  266. }
  267. function resolveTiming(timings, errors, allowNegativeValues) {
  268. return timings.hasOwnProperty('duration') ?
  269. timings :
  270. parseTimeExpression(timings, errors, allowNegativeValues);
  271. }
  272. function parseTimeExpression(exp, errors, allowNegativeValues) {
  273. var regex = /^(-?[\.\d]+)(m?s)(?:\s+(-?[\.\d]+)(m?s))?(?:\s+([-a-z]+(?:\(.+?\))?))?$/i;
  274. var duration;
  275. var delay = 0;
  276. var easing = '';
  277. if (typeof exp === 'string') {
  278. var matches = exp.match(regex);
  279. if (matches === null) {
  280. errors.push("The provided timing value \"" + exp + "\" is invalid.");
  281. return { duration: 0, delay: 0, easing: '' };
  282. }
  283. duration = _convertTimeValueToMS(parseFloat(matches[1]), matches[2]);
  284. var delayMatch = matches[3];
  285. if (delayMatch != null) {
  286. delay = _convertTimeValueToMS(parseFloat(delayMatch), matches[4]);
  287. }
  288. var easingVal = matches[5];
  289. if (easingVal) {
  290. easing = easingVal;
  291. }
  292. }
  293. else {
  294. duration = exp;
  295. }
  296. if (!allowNegativeValues) {
  297. var containsErrors = false;
  298. var startIndex = errors.length;
  299. if (duration < 0) {
  300. errors.push("Duration values below 0 are not allowed for this animation step.");
  301. containsErrors = true;
  302. }
  303. if (delay < 0) {
  304. errors.push("Delay values below 0 are not allowed for this animation step.");
  305. containsErrors = true;
  306. }
  307. if (containsErrors) {
  308. errors.splice(startIndex, 0, "The provided timing value \"" + exp + "\" is invalid.");
  309. }
  310. }
  311. return { duration: duration, delay: delay, easing: easing };
  312. }
  313. function copyObj(obj, destination) {
  314. if (destination === void 0) { destination = {}; }
  315. Object.keys(obj).forEach(function (prop) { destination[prop] = obj[prop]; });
  316. return destination;
  317. }
  318. function normalizeStyles(styles) {
  319. var normalizedStyles = {};
  320. if (Array.isArray(styles)) {
  321. styles.forEach(function (data) { return copyStyles(data, false, normalizedStyles); });
  322. }
  323. else {
  324. copyStyles(styles, false, normalizedStyles);
  325. }
  326. return normalizedStyles;
  327. }
  328. function copyStyles(styles, readPrototype, destination) {
  329. if (destination === void 0) { destination = {}; }
  330. if (readPrototype) {
  331. // we make use of a for-in loop so that the
  332. // prototypically inherited properties are
  333. // revealed from the backFill map
  334. for (var prop in styles) {
  335. destination[prop] = styles[prop];
  336. }
  337. }
  338. else {
  339. copyObj(styles, destination);
  340. }
  341. return destination;
  342. }
  343. function getStyleAttributeString(element, key, value) {
  344. // Return the key-value pair string to be added to the style attribute for the
  345. // given CSS style key.
  346. if (value) {
  347. return key + ':' + value + ';';
  348. }
  349. else {
  350. return '';
  351. }
  352. }
  353. function writeStyleAttribute(element) {
  354. // Read the style property of the element and manually reflect it to the
  355. // style attribute. This is needed because Domino on platform-server doesn't
  356. // understand the full set of allowed CSS properties and doesn't reflect some
  357. // of them automatically.
  358. var styleAttrValue = '';
  359. for (var i = 0; i < element.style.length; i++) {
  360. var key = element.style.item(i);
  361. styleAttrValue += getStyleAttributeString(element, key, element.style.getPropertyValue(key));
  362. }
  363. for (var key in element.style) {
  364. // Skip internal Domino properties that don't need to be reflected.
  365. if (!element.style.hasOwnProperty(key) || key.startsWith('_')) {
  366. continue;
  367. }
  368. var dashKey = camelCaseToDashCase(key);
  369. styleAttrValue += getStyleAttributeString(element, dashKey, element.style[key]);
  370. }
  371. element.setAttribute('style', styleAttrValue);
  372. }
  373. function setStyles(element, styles, formerStyles) {
  374. if (element['style']) {
  375. Object.keys(styles).forEach(function (prop) {
  376. var camelProp = dashCaseToCamelCase(prop);
  377. if (formerStyles && !formerStyles.hasOwnProperty(prop)) {
  378. formerStyles[prop] = element.style[camelProp];
  379. }
  380. element.style[camelProp] = styles[prop];
  381. });
  382. // On the server set the 'style' attribute since it's not automatically reflected.
  383. if (isNode()) {
  384. writeStyleAttribute(element);
  385. }
  386. }
  387. }
  388. function eraseStyles(element, styles) {
  389. if (element['style']) {
  390. Object.keys(styles).forEach(function (prop) {
  391. var camelProp = dashCaseToCamelCase(prop);
  392. element.style[camelProp] = '';
  393. });
  394. // On the server set the 'style' attribute since it's not automatically reflected.
  395. if (isNode()) {
  396. writeStyleAttribute(element);
  397. }
  398. }
  399. }
  400. function normalizeAnimationEntry(steps) {
  401. if (Array.isArray(steps)) {
  402. if (steps.length == 1)
  403. return steps[0];
  404. return sequence(steps);
  405. }
  406. return steps;
  407. }
  408. function validateStyleParams(value, options, errors) {
  409. var params = options.params || {};
  410. var matches = extractStyleParams(value);
  411. if (matches.length) {
  412. matches.forEach(function (varName) {
  413. if (!params.hasOwnProperty(varName)) {
  414. errors.push("Unable to resolve the local animation param " + varName + " in the given list of values");
  415. }
  416. });
  417. }
  418. }
  419. var PARAM_REGEX = new RegExp(SUBSTITUTION_EXPR_START + "\\s*(.+?)\\s*" + SUBSTITUTION_EXPR_END, 'g');
  420. function extractStyleParams(value) {
  421. var params = [];
  422. if (typeof value === 'string') {
  423. var val = value.toString();
  424. var match = void 0;
  425. while (match = PARAM_REGEX.exec(val)) {
  426. params.push(match[1]);
  427. }
  428. PARAM_REGEX.lastIndex = 0;
  429. }
  430. return params;
  431. }
  432. function interpolateParams(value, params, errors) {
  433. var original = value.toString();
  434. var str = original.replace(PARAM_REGEX, function (_, varName) {
  435. var localVal = params[varName];
  436. // this means that the value was never overridden by the data passed in by the user
  437. if (!params.hasOwnProperty(varName)) {
  438. errors.push("Please provide a value for the animation param " + varName);
  439. localVal = '';
  440. }
  441. return localVal.toString();
  442. });
  443. // we do this to assert that numeric values stay as they are
  444. return str == original ? value : str;
  445. }
  446. function iteratorToArray(iterator) {
  447. var arr = [];
  448. var item = iterator.next();
  449. while (!item.done) {
  450. arr.push(item.value);
  451. item = iterator.next();
  452. }
  453. return arr;
  454. }
  455. var DASH_CASE_REGEXP = /-+([a-z0-9])/g;
  456. function dashCaseToCamelCase(input) {
  457. return input.replace(DASH_CASE_REGEXP, function () {
  458. var m = [];
  459. for (var _i = 0; _i < arguments.length; _i++) {
  460. m[_i] = arguments[_i];
  461. }
  462. return m[1].toUpperCase();
  463. });
  464. }
  465. function camelCaseToDashCase(input) {
  466. return input.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
  467. }
  468. function allowPreviousPlayerStylesMerge(duration, delay) {
  469. return duration === 0 || delay === 0;
  470. }
  471. function balancePreviousStylesIntoKeyframes(element, keyframes, previousStyles) {
  472. var previousStyleProps = Object.keys(previousStyles);
  473. if (previousStyleProps.length && keyframes.length) {
  474. var startingKeyframe_1 = keyframes[0];
  475. var missingStyleProps_1 = [];
  476. previousStyleProps.forEach(function (prop) {
  477. if (!startingKeyframe_1.hasOwnProperty(prop)) {
  478. missingStyleProps_1.push(prop);
  479. }
  480. startingKeyframe_1[prop] = previousStyles[prop];
  481. });
  482. if (missingStyleProps_1.length) {
  483. var _loop_1 = function () {
  484. var kf = keyframes[i];
  485. missingStyleProps_1.forEach(function (prop) { kf[prop] = computeStyle(element, prop); });
  486. };
  487. // tslint:disable-next-line
  488. for (var i = 1; i < keyframes.length; i++) {
  489. _loop_1();
  490. }
  491. }
  492. }
  493. return keyframes;
  494. }
  495. function visitDslNode(visitor, node, context) {
  496. switch (node.type) {
  497. case 7 /* Trigger */:
  498. return visitor.visitTrigger(node, context);
  499. case 0 /* State */:
  500. return visitor.visitState(node, context);
  501. case 1 /* Transition */:
  502. return visitor.visitTransition(node, context);
  503. case 2 /* Sequence */:
  504. return visitor.visitSequence(node, context);
  505. case 3 /* Group */:
  506. return visitor.visitGroup(node, context);
  507. case 4 /* Animate */:
  508. return visitor.visitAnimate(node, context);
  509. case 5 /* Keyframes */:
  510. return visitor.visitKeyframes(node, context);
  511. case 6 /* Style */:
  512. return visitor.visitStyle(node, context);
  513. case 8 /* Reference */:
  514. return visitor.visitReference(node, context);
  515. case 9 /* AnimateChild */:
  516. return visitor.visitAnimateChild(node, context);
  517. case 10 /* AnimateRef */:
  518. return visitor.visitAnimateRef(node, context);
  519. case 11 /* Query */:
  520. return visitor.visitQuery(node, context);
  521. case 12 /* Stagger */:
  522. return visitor.visitStagger(node, context);
  523. default:
  524. throw new Error("Unable to resolve animation metadata node #" + node.type);
  525. }
  526. }
  527. function computeStyle(element, prop) {
  528. return window.getComputedStyle(element)[prop];
  529. }
  530. /**
  531. * @license
  532. * Copyright Google Inc. All Rights Reserved.
  533. *
  534. * Use of this source code is governed by an MIT-style license that can be
  535. * found in the LICENSE file at https://angular.io/license
  536. */
  537. var ANY_STATE = '*';
  538. function parseTransitionExpr(transitionValue, errors) {
  539. var expressions = [];
  540. if (typeof transitionValue == 'string') {
  541. transitionValue
  542. .split(/\s*,\s*/)
  543. .forEach(function (str) { return parseInnerTransitionStr(str, expressions, errors); });
  544. }
  545. else {
  546. expressions.push(transitionValue);
  547. }
  548. return expressions;
  549. }
  550. function parseInnerTransitionStr(eventStr, expressions, errors) {
  551. if (eventStr[0] == ':') {
  552. var result = parseAnimationAlias(eventStr, errors);
  553. if (typeof result == 'function') {
  554. expressions.push(result);
  555. return;
  556. }
  557. eventStr = result;
  558. }
  559. var match = eventStr.match(/^(\*|[-\w]+)\s*(<?[=-]>)\s*(\*|[-\w]+)$/);
  560. if (match == null || match.length < 4) {
  561. errors.push("The provided transition expression \"" + eventStr + "\" is not supported");
  562. return expressions;
  563. }
  564. var fromState = match[1];
  565. var separator = match[2];
  566. var toState = match[3];
  567. expressions.push(makeLambdaFromStates(fromState, toState));
  568. var isFullAnyStateExpr = fromState == ANY_STATE && toState == ANY_STATE;
  569. if (separator[0] == '<' && !isFullAnyStateExpr) {
  570. expressions.push(makeLambdaFromStates(toState, fromState));
  571. }
  572. }
  573. function parseAnimationAlias(alias, errors) {
  574. switch (alias) {
  575. case ':enter':
  576. return 'void => *';
  577. case ':leave':
  578. return '* => void';
  579. case ':increment':
  580. return function (fromState, toState) { return parseFloat(toState) > parseFloat(fromState); };
  581. case ':decrement':
  582. return function (fromState, toState) { return parseFloat(toState) < parseFloat(fromState); };
  583. default:
  584. errors.push("The transition alias value \"" + alias + "\" is not supported");
  585. return '* => *';
  586. }
  587. }
  588. // DO NOT REFACTOR ... keep the follow set instantiations
  589. // with the values intact (closure compiler for some reason
  590. // removes follow-up lines that add the values outside of
  591. // the constructor...
  592. var TRUE_BOOLEAN_VALUES = new Set(['true', '1']);
  593. var FALSE_BOOLEAN_VALUES = new Set(['false', '0']);
  594. function makeLambdaFromStates(lhs, rhs) {
  595. var LHS_MATCH_BOOLEAN = TRUE_BOOLEAN_VALUES.has(lhs) || FALSE_BOOLEAN_VALUES.has(lhs);
  596. var RHS_MATCH_BOOLEAN = TRUE_BOOLEAN_VALUES.has(rhs) || FALSE_BOOLEAN_VALUES.has(rhs);
  597. return function (fromState, toState) {
  598. var lhsMatch = lhs == ANY_STATE || lhs == fromState;
  599. var rhsMatch = rhs == ANY_STATE || rhs == toState;
  600. if (!lhsMatch && LHS_MATCH_BOOLEAN && typeof fromState === 'boolean') {
  601. lhsMatch = fromState ? TRUE_BOOLEAN_VALUES.has(lhs) : FALSE_BOOLEAN_VALUES.has(lhs);
  602. }
  603. if (!rhsMatch && RHS_MATCH_BOOLEAN && typeof toState === 'boolean') {
  604. rhsMatch = toState ? TRUE_BOOLEAN_VALUES.has(rhs) : FALSE_BOOLEAN_VALUES.has(rhs);
  605. }
  606. return lhsMatch && rhsMatch;
  607. };
  608. }
  609. var SELF_TOKEN = ':self';
  610. var SELF_TOKEN_REGEX = new RegExp("s*" + SELF_TOKEN + "s*,?", 'g');
  611. /*
  612. * [Validation]
  613. * The visitor code below will traverse the animation AST generated by the animation verb functions
  614. * (the output is a tree of objects) and attempt to perform a series of validations on the data. The
  615. * following corner-cases will be validated:
  616. *
  617. * 1. Overlap of animations
  618. * Given that a CSS property cannot be animated in more than one place at the same time, it's
  619. * important that this behavior is detected and validated. The way in which this occurs is that
  620. * each time a style property is examined, a string-map containing the property will be updated with
  621. * the start and end times for when the property is used within an animation step.
  622. *
  623. * If there are two or more parallel animations that are currently running (these are invoked by the
  624. * group()) on the same element then the validator will throw an error. Since the start/end timing
  625. * values are collected for each property then if the current animation step is animating the same
  626. * property and its timing values fall anywhere into the window of time that the property is
  627. * currently being animated within then this is what causes an error.
  628. *
  629. * 2. Timing values
  630. * The validator will validate to see if a timing value of `duration delay easing` or
  631. * `durationNumber` is valid or not.
  632. *
  633. * (note that upon validation the code below will replace the timing data with an object containing
  634. * {duration,delay,easing}.
  635. *
  636. * 3. Offset Validation
  637. * Each of the style() calls are allowed to have an offset value when placed inside of keyframes().
  638. * Offsets within keyframes() are considered valid when:
  639. *
  640. * - No offsets are used at all
  641. * - Each style() entry contains an offset value
  642. * - Each offset is between 0 and 1
  643. * - Each offset is greater to or equal than the previous one
  644. *
  645. * Otherwise an error will be thrown.
  646. */
  647. function buildAnimationAst(driver, metadata, errors) {
  648. return new AnimationAstBuilderVisitor(driver).build(metadata, errors);
  649. }
  650. var ROOT_SELECTOR = '';
  651. var AnimationAstBuilderVisitor = /** @class */ (function () {
  652. function AnimationAstBuilderVisitor(_driver) {
  653. this._driver = _driver;
  654. }
  655. AnimationAstBuilderVisitor.prototype.build = function (metadata, errors) {
  656. var context = new AnimationAstBuilderContext(errors);
  657. this._resetContextStyleTimingState(context);
  658. return visitDslNode(this, normalizeAnimationEntry(metadata), context);
  659. };
  660. AnimationAstBuilderVisitor.prototype._resetContextStyleTimingState = function (context) {
  661. context.currentQuerySelector = ROOT_SELECTOR;
  662. context.collectedStyles = {};
  663. context.collectedStyles[ROOT_SELECTOR] = {};
  664. context.currentTime = 0;
  665. };
  666. AnimationAstBuilderVisitor.prototype.visitTrigger = function (metadata, context) {
  667. var _this = this;
  668. var queryCount = context.queryCount = 0;
  669. var depCount = context.depCount = 0;
  670. var states = [];
  671. var transitions = [];
  672. if (metadata.name.charAt(0) == '@') {
  673. context.errors.push('animation triggers cannot be prefixed with an `@` sign (e.g. trigger(\'@foo\', [...]))');
  674. }
  675. metadata.definitions.forEach(function (def) {
  676. _this._resetContextStyleTimingState(context);
  677. if (def.type == 0 /* State */) {
  678. var stateDef_1 = def;
  679. var name_1 = stateDef_1.name;
  680. name_1.toString().split(/\s*,\s*/).forEach(function (n) {
  681. stateDef_1.name = n;
  682. states.push(_this.visitState(stateDef_1, context));
  683. });
  684. stateDef_1.name = name_1;
  685. }
  686. else if (def.type == 1 /* Transition */) {
  687. var transition = _this.visitTransition(def, context);
  688. queryCount += transition.queryCount;
  689. depCount += transition.depCount;
  690. transitions.push(transition);
  691. }
  692. else {
  693. context.errors.push('only state() and transition() definitions can sit inside of a trigger()');
  694. }
  695. });
  696. return {
  697. type: 7 /* Trigger */,
  698. name: metadata.name, states: states, transitions: transitions, queryCount: queryCount, depCount: depCount,
  699. options: null
  700. };
  701. };
  702. AnimationAstBuilderVisitor.prototype.visitState = function (metadata, context) {
  703. var styleAst = this.visitStyle(metadata.styles, context);
  704. var astParams = (metadata.options && metadata.options.params) || null;
  705. if (styleAst.containsDynamicStyles) {
  706. var missingSubs_1 = new Set();
  707. var params_1 = astParams || {};
  708. styleAst.styles.forEach(function (value) {
  709. if (isObject(value)) {
  710. var stylesObj_1 = value;
  711. Object.keys(stylesObj_1).forEach(function (prop) {
  712. extractStyleParams(stylesObj_1[prop]).forEach(function (sub) {
  713. if (!params_1.hasOwnProperty(sub)) {
  714. missingSubs_1.add(sub);
  715. }
  716. });
  717. });
  718. }
  719. });
  720. if (missingSubs_1.size) {
  721. var missingSubsArr = iteratorToArray(missingSubs_1.values());
  722. context.errors.push("state(\"" + metadata.name + "\", ...) must define default values for all the following style substitutions: " + missingSubsArr.join(', '));
  723. }
  724. }
  725. return {
  726. type: 0 /* State */,
  727. name: metadata.name,
  728. style: styleAst,
  729. options: astParams ? { params: astParams } : null
  730. };
  731. };
  732. AnimationAstBuilderVisitor.prototype.visitTransition = function (metadata, context) {
  733. context.queryCount = 0;
  734. context.depCount = 0;
  735. var animation = visitDslNode(this, normalizeAnimationEntry(metadata.animation), context);
  736. var matchers = parseTransitionExpr(metadata.expr, context.errors);
  737. return {
  738. type: 1 /* Transition */,
  739. matchers: matchers,
  740. animation: animation,
  741. queryCount: context.queryCount,
  742. depCount: context.depCount,
  743. options: normalizeAnimationOptions(metadata.options)
  744. };
  745. };
  746. AnimationAstBuilderVisitor.prototype.visitSequence = function (metadata, context) {
  747. var _this = this;
  748. return {
  749. type: 2 /* Sequence */,
  750. steps: metadata.steps.map(function (s) { return visitDslNode(_this, s, context); }),
  751. options: normalizeAnimationOptions(metadata.options)
  752. };
  753. };
  754. AnimationAstBuilderVisitor.prototype.visitGroup = function (metadata, context) {
  755. var _this = this;
  756. var currentTime = context.currentTime;
  757. var furthestTime = 0;
  758. var steps = metadata.steps.map(function (step) {
  759. context.currentTime = currentTime;
  760. var innerAst = visitDslNode(_this, step, context);
  761. furthestTime = Math.max(furthestTime, context.currentTime);
  762. return innerAst;
  763. });
  764. context.currentTime = furthestTime;
  765. return {
  766. type: 3 /* Group */,
  767. steps: steps,
  768. options: normalizeAnimationOptions(metadata.options)
  769. };
  770. };
  771. AnimationAstBuilderVisitor.prototype.visitAnimate = function (metadata, context) {
  772. var timingAst = constructTimingAst(metadata.timings, context.errors);
  773. context.currentAnimateTimings = timingAst;
  774. var styleAst;
  775. var styleMetadata = metadata.styles ? metadata.styles : style({});
  776. if (styleMetadata.type == 5 /* Keyframes */) {
  777. styleAst = this.visitKeyframes(styleMetadata, context);
  778. }
  779. else {
  780. var styleMetadata_1 = metadata.styles;
  781. var isEmpty = false;
  782. if (!styleMetadata_1) {
  783. isEmpty = true;
  784. var newStyleData = {};
  785. if (timingAst.easing) {
  786. newStyleData['easing'] = timingAst.easing;
  787. }
  788. styleMetadata_1 = style(newStyleData);
  789. }
  790. context.currentTime += timingAst.duration + timingAst.delay;
  791. var _styleAst = this.visitStyle(styleMetadata_1, context);
  792. _styleAst.isEmptyStep = isEmpty;
  793. styleAst = _styleAst;
  794. }
  795. context.currentAnimateTimings = null;
  796. return {
  797. type: 4 /* Animate */,
  798. timings: timingAst,
  799. style: styleAst,
  800. options: null
  801. };
  802. };
  803. AnimationAstBuilderVisitor.prototype.visitStyle = function (metadata, context) {
  804. var ast = this._makeStyleAst(metadata, context);
  805. this._validateStyleAst(ast, context);
  806. return ast;
  807. };
  808. AnimationAstBuilderVisitor.prototype._makeStyleAst = function (metadata, context) {
  809. var styles = [];
  810. if (Array.isArray(metadata.styles)) {
  811. metadata.styles.forEach(function (styleTuple) {
  812. if (typeof styleTuple == 'string') {
  813. if (styleTuple == AUTO_STYLE) {
  814. styles.push(styleTuple);
  815. }
  816. else {
  817. context.errors.push("The provided style string value " + styleTuple + " is not allowed.");
  818. }
  819. }
  820. else {
  821. styles.push(styleTuple);
  822. }
  823. });
  824. }
  825. else {
  826. styles.push(metadata.styles);
  827. }
  828. var containsDynamicStyles = false;
  829. var collectedEasing = null;
  830. styles.forEach(function (styleData) {
  831. if (isObject(styleData)) {
  832. var styleMap = styleData;
  833. var easing = styleMap['easing'];
  834. if (easing) {
  835. collectedEasing = easing;
  836. delete styleMap['easing'];
  837. }
  838. if (!containsDynamicStyles) {
  839. for (var prop in styleMap) {
  840. var value = styleMap[prop];
  841. if (value.toString().indexOf(SUBSTITUTION_EXPR_START) >= 0) {
  842. containsDynamicStyles = true;
  843. break;
  844. }
  845. }
  846. }
  847. }
  848. });
  849. return {
  850. type: 6 /* Style */,
  851. styles: styles,
  852. easing: collectedEasing,
  853. offset: metadata.offset, containsDynamicStyles: containsDynamicStyles,
  854. options: null
  855. };
  856. };
  857. AnimationAstBuilderVisitor.prototype._validateStyleAst = function (ast, context) {
  858. var _this = this;
  859. var timings = context.currentAnimateTimings;
  860. var endTime = context.currentTime;
  861. var startTime = context.currentTime;
  862. if (timings && startTime > 0) {
  863. startTime -= timings.duration + timings.delay;
  864. }
  865. ast.styles.forEach(function (tuple) {
  866. if (typeof tuple == 'string')
  867. return;
  868. Object.keys(tuple).forEach(function (prop) {
  869. if (!_this._driver.validateStyleProperty(prop)) {
  870. context.errors.push("The provided animation property \"" + prop + "\" is not a supported CSS property for animations");
  871. return;
  872. }
  873. var collectedStyles = context.collectedStyles[context.currentQuerySelector];
  874. var collectedEntry = collectedStyles[prop];
  875. var updateCollectedStyle = true;
  876. if (collectedEntry) {
  877. if (startTime != endTime && startTime >= collectedEntry.startTime &&
  878. endTime <= collectedEntry.endTime) {
  879. context.errors.push("The CSS property \"" + prop + "\" that exists between the times of \"" + collectedEntry.startTime + "ms\" and \"" + collectedEntry.endTime + "ms\" is also being animated in a parallel animation between the times of \"" + startTime + "ms\" and \"" + endTime + "ms\"");
  880. updateCollectedStyle = false;
  881. }
  882. // we always choose the smaller start time value since we
  883. // want to have a record of the entire animation window where
  884. // the style property is being animated in between
  885. startTime = collectedEntry.startTime;
  886. }
  887. if (updateCollectedStyle) {
  888. collectedStyles[prop] = { startTime: startTime, endTime: endTime };
  889. }
  890. if (context.options) {
  891. validateStyleParams(tuple[prop], context.options, context.errors);
  892. }
  893. });
  894. });
  895. };
  896. AnimationAstBuilderVisitor.prototype.visitKeyframes = function (metadata, context) {
  897. var _this = this;
  898. var ast = { type: 5 /* Keyframes */, styles: [], options: null };
  899. if (!context.currentAnimateTimings) {
  900. context.errors.push("keyframes() must be placed inside of a call to animate()");
  901. return ast;
  902. }
  903. var MAX_KEYFRAME_OFFSET = 1;
  904. var totalKeyframesWithOffsets = 0;
  905. var offsets = [];
  906. var offsetsOutOfOrder = false;
  907. var keyframesOutOfRange = false;
  908. var previousOffset = 0;
  909. var keyframes = metadata.steps.map(function (styles) {
  910. var style = _this._makeStyleAst(styles, context);
  911. var offsetVal = style.offset != null ? style.offset : consumeOffset(style.styles);
  912. var offset = 0;
  913. if (offsetVal != null) {
  914. totalKeyframesWithOffsets++;
  915. offset = style.offset = offsetVal;
  916. }
  917. keyframesOutOfRange = keyframesOutOfRange || offset < 0 || offset > 1;
  918. offsetsOutOfOrder = offsetsOutOfOrder || offset < previousOffset;
  919. previousOffset = offset;
  920. offsets.push(offset);
  921. return style;
  922. });
  923. if (keyframesOutOfRange) {
  924. context.errors.push("Please ensure that all keyframe offsets are between 0 and 1");
  925. }
  926. if (offsetsOutOfOrder) {
  927. context.errors.push("Please ensure that all keyframe offsets are in order");
  928. }
  929. var length = metadata.steps.length;
  930. var generatedOffset = 0;
  931. if (totalKeyframesWithOffsets > 0 && totalKeyframesWithOffsets < length) {
  932. context.errors.push("Not all style() steps within the declared keyframes() contain offsets");
  933. }
  934. else if (totalKeyframesWithOffsets == 0) {
  935. generatedOffset = MAX_KEYFRAME_OFFSET / (length - 1);
  936. }
  937. var limit = length - 1;
  938. var currentTime = context.currentTime;
  939. var currentAnimateTimings = context.currentAnimateTimings;
  940. var animateDuration = currentAnimateTimings.duration;
  941. keyframes.forEach(function (kf, i) {
  942. var offset = generatedOffset > 0 ? (i == limit ? 1 : (generatedOffset * i)) : offsets[i];
  943. var durationUpToThisFrame = offset * animateDuration;
  944. context.currentTime = currentTime + currentAnimateTimings.delay + durationUpToThisFrame;
  945. currentAnimateTimings.duration = durationUpToThisFrame;
  946. _this._validateStyleAst(kf, context);
  947. kf.offset = offset;
  948. ast.styles.push(kf);
  949. });
  950. return ast;
  951. };
  952. AnimationAstBuilderVisitor.prototype.visitReference = function (metadata, context) {
  953. return {
  954. type: 8 /* Reference */,
  955. animation: visitDslNode(this, normalizeAnimationEntry(metadata.animation), context),
  956. options: normalizeAnimationOptions(metadata.options)
  957. };
  958. };
  959. AnimationAstBuilderVisitor.prototype.visitAnimateChild = function (metadata, context) {
  960. context.depCount++;
  961. return {
  962. type: 9 /* AnimateChild */,
  963. options: normalizeAnimationOptions(metadata.options)
  964. };
  965. };
  966. AnimationAstBuilderVisitor.prototype.visitAnimateRef = function (metadata, context) {
  967. return {
  968. type: 10 /* AnimateRef */,
  969. animation: this.visitReference(metadata.animation, context),
  970. options: normalizeAnimationOptions(metadata.options)
  971. };
  972. };
  973. AnimationAstBuilderVisitor.prototype.visitQuery = function (metadata, context) {
  974. var parentSelector = context.currentQuerySelector;
  975. var options = (metadata.options || {});
  976. context.queryCount++;
  977. context.currentQuery = metadata;
  978. var _a = __read(normalizeSelector(metadata.selector), 2), selector = _a[0], includeSelf = _a[1];
  979. context.currentQuerySelector =
  980. parentSelector.length ? (parentSelector + ' ' + selector) : selector;
  981. getOrSetAsInMap(context.collectedStyles, context.currentQuerySelector, {});
  982. var animation = visitDslNode(this, normalizeAnimationEntry(metadata.animation), context);
  983. context.currentQuery = null;
  984. context.currentQuerySelector = parentSelector;
  985. return {
  986. type: 11 /* Query */,
  987. selector: selector,
  988. limit: options.limit || 0,
  989. optional: !!options.optional, includeSelf: includeSelf, animation: animation,
  990. originalSelector: metadata.selector,
  991. options: normalizeAnimationOptions(metadata.options)
  992. };
  993. };
  994. AnimationAstBuilderVisitor.prototype.visitStagger = function (metadata, context) {
  995. if (!context.currentQuery) {
  996. context.errors.push("stagger() can only be used inside of query()");
  997. }
  998. var timings = metadata.timings === 'full' ?
  999. { duration: 0, delay: 0, easing: 'full' } :
  1000. resolveTiming(metadata.timings, context.errors, true);
  1001. return {
  1002. type: 12 /* Stagger */,
  1003. animation: visitDslNode(this, normalizeAnimationEntry(metadata.animation), context), timings: timings,
  1004. options: null
  1005. };
  1006. };
  1007. return AnimationAstBuilderVisitor;
  1008. }());
  1009. function normalizeSelector(selector) {
  1010. var hasAmpersand = selector.split(/\s*,\s*/).find(function (token) { return token == SELF_TOKEN; }) ? true : false;
  1011. if (hasAmpersand) {
  1012. selector = selector.replace(SELF_TOKEN_REGEX, '');
  1013. }
  1014. // the :enter and :leave selectors are filled in at runtime during timeline building
  1015. selector = selector.replace(/@\*/g, NG_TRIGGER_SELECTOR)
  1016. .replace(/@\w+/g, function (match) { return NG_TRIGGER_SELECTOR + '-' + match.substr(1); })
  1017. .replace(/:animating/g, NG_ANIMATING_SELECTOR);
  1018. return [selector, hasAmpersand];
  1019. }
  1020. function normalizeParams(obj) {
  1021. return obj ? copyObj(obj) : null;
  1022. }
  1023. var AnimationAstBuilderContext = /** @class */ (function () {
  1024. function AnimationAstBuilderContext(errors) {
  1025. this.errors = errors;
  1026. this.queryCount = 0;
  1027. this.depCount = 0;
  1028. this.currentTransition = null;
  1029. this.currentQuery = null;
  1030. this.currentQuerySelector = null;
  1031. this.currentAnimateTimings = null;
  1032. this.currentTime = 0;
  1033. this.collectedStyles = {};
  1034. this.options = null;
  1035. }
  1036. return AnimationAstBuilderContext;
  1037. }());
  1038. function consumeOffset(styles) {
  1039. if (typeof styles == 'string')
  1040. return null;
  1041. var offset = null;
  1042. if (Array.isArray(styles)) {
  1043. styles.forEach(function (styleTuple) {
  1044. if (isObject(styleTuple) && styleTuple.hasOwnProperty('offset')) {
  1045. var obj = styleTuple;
  1046. offset = parseFloat(obj['offset']);
  1047. delete obj['offset'];
  1048. }
  1049. });
  1050. }
  1051. else if (isObject(styles) && styles.hasOwnProperty('offset')) {
  1052. var obj = styles;
  1053. offset = parseFloat(obj['offset']);
  1054. delete obj['offset'];
  1055. }
  1056. return offset;
  1057. }
  1058. function isObject(value) {
  1059. return !Array.isArray(value) && typeof value == 'object';
  1060. }
  1061. function constructTimingAst(value, errors) {
  1062. var timings = null;
  1063. if (value.hasOwnProperty('duration')) {
  1064. timings = value;
  1065. }
  1066. else if (typeof value == 'number') {
  1067. var duration = resolveTiming(value, errors).duration;
  1068. return makeTimingAst(duration, 0, '');
  1069. }
  1070. var strValue = value;
  1071. var isDynamic = strValue.split(/\s+/).some(function (v) { return v.charAt(0) == '{' && v.charAt(1) == '{'; });
  1072. if (isDynamic) {
  1073. var ast = makeTimingAst(0, 0, '');
  1074. ast.dynamic = true;
  1075. ast.strValue = strValue;
  1076. return ast;
  1077. }
  1078. timings = timings || resolveTiming(strValue, errors);
  1079. return makeTimingAst(timings.duration, timings.delay, timings.easing);
  1080. }
  1081. function normalizeAnimationOptions(options) {
  1082. if (options) {
  1083. options = copyObj(options);
  1084. if (options['params']) {
  1085. options['params'] = normalizeParams(options['params']);
  1086. }
  1087. }
  1088. else {
  1089. options = {};
  1090. }
  1091. return options;
  1092. }
  1093. function makeTimingAst(duration, delay, easing) {
  1094. return { duration: duration, delay: delay, easing: easing };
  1095. }
  1096. function createTimelineInstruction(element, keyframes, preStyleProps, postStyleProps, duration, delay, easing, subTimeline) {
  1097. if (easing === void 0) { easing = null; }
  1098. if (subTimeline === void 0) { subTimeline = false; }
  1099. return {
  1100. type: 1 /* TimelineAnimation */,
  1101. element: element,
  1102. keyframes: keyframes,
  1103. preStyleProps: preStyleProps,
  1104. postStyleProps: postStyleProps,
  1105. duration: duration,
  1106. delay: delay,
  1107. totalTime: duration + delay, easing: easing, subTimeline: subTimeline
  1108. };
  1109. }
  1110. var ElementInstructionMap = /** @class */ (function () {
  1111. function ElementInstructionMap() {
  1112. this._map = new Map();
  1113. }
  1114. ElementInstructionMap.prototype.consume = function (element) {
  1115. var instructions = this._map.get(element);
  1116. if (instructions) {
  1117. this._map.delete(element);
  1118. }
  1119. else {
  1120. instructions = [];
  1121. }
  1122. return instructions;
  1123. };
  1124. ElementInstructionMap.prototype.append = function (element, instructions) {
  1125. var existingInstructions = this._map.get(element);
  1126. if (!existingInstructions) {
  1127. this._map.set(element, existingInstructions = []);
  1128. }
  1129. existingInstructions.push.apply(existingInstructions, __spread(instructions));
  1130. };
  1131. ElementInstructionMap.prototype.has = function (element) { return this._map.has(element); };
  1132. ElementInstructionMap.prototype.clear = function () { this._map.clear(); };
  1133. return ElementInstructionMap;
  1134. }());
  1135. var ONE_FRAME_IN_MILLISECONDS = 1;
  1136. var ENTER_TOKEN = ':enter';
  1137. var ENTER_TOKEN_REGEX = new RegExp(ENTER_TOKEN, 'g');
  1138. var LEAVE_TOKEN = ':leave';
  1139. var LEAVE_TOKEN_REGEX = new RegExp(LEAVE_TOKEN, 'g');
  1140. /*
  1141. * The code within this file aims to generate web-animations-compatible keyframes from Angular's
  1142. * animation DSL code.
  1143. *
  1144. * The code below will be converted from:
  1145. *
  1146. * ```
  1147. * sequence([
  1148. * style({ opacity: 0 }),
  1149. * animate(1000, style({ opacity: 0 }))
  1150. * ])
  1151. * ```
  1152. *
  1153. * To:
  1154. * ```
  1155. * keyframes = [{ opacity: 0, offset: 0 }, { opacity: 1, offset: 1 }]
  1156. * duration = 1000
  1157. * delay = 0
  1158. * easing = ''
  1159. * ```
  1160. *
  1161. * For this operation to cover the combination of animation verbs (style, animate, group, etc...) a
  1162. * combination of prototypical inheritance, AST traversal and merge-sort-like algorithms are used.
  1163. *
  1164. * [AST Traversal]
  1165. * Each of the animation verbs, when executed, will return an string-map object representing what
  1166. * type of action it is (style, animate, group, etc...) and the data associated with it. This means
  1167. * that when functional composition mix of these functions is evaluated (like in the example above)
  1168. * then it will end up producing a tree of objects representing the animation itself.
  1169. *
  1170. * When this animation object tree is processed by the visitor code below it will visit each of the
  1171. * verb statements within the visitor. And during each visit it will build the context of the
  1172. * animation keyframes by interacting with the `TimelineBuilder`.
  1173. *
  1174. * [TimelineBuilder]
  1175. * This class is responsible for tracking the styles and building a series of keyframe objects for a
  1176. * timeline between a start and end time. The builder starts off with an initial timeline and each
  1177. * time the AST comes across a `group()`, `keyframes()` or a combination of the two wihtin a
  1178. * `sequence()` then it will generate a sub timeline for each step as well as a new one after
  1179. * they are complete.
  1180. *
  1181. * As the AST is traversed, the timing state on each of the timelines will be incremented. If a sub
  1182. * timeline was created (based on one of the cases above) then the parent timeline will attempt to
  1183. * merge the styles used within the sub timelines into itself (only with group() this will happen).
  1184. * This happens with a merge operation (much like how the merge works in mergesort) and it will only
  1185. * copy the most recently used styles from the sub timelines into the parent timeline. This ensures
  1186. * that if the styles are used later on in another phase of the animation then they will be the most
  1187. * up-to-date values.
  1188. *
  1189. * [How Missing Styles Are Updated]
  1190. * Each timeline has a `backFill` property which is responsible for filling in new styles into
  1191. * already processed keyframes if a new style shows up later within the animation sequence.
  1192. *
  1193. * ```
  1194. * sequence([
  1195. * style({ width: 0 }),
  1196. * animate(1000, style({ width: 100 })),
  1197. * animate(1000, style({ width: 200 })),
  1198. * animate(1000, style({ width: 300 }))
  1199. * animate(1000, style({ width: 400, height: 400 })) // notice how `height` doesn't exist anywhere
  1200. * else
  1201. * ])
  1202. * ```
  1203. *
  1204. * What is happening here is that the `height` value is added later in the sequence, but is missing
  1205. * from all previous animation steps. Therefore when a keyframe is created it would also be missing
  1206. * from all previous keyframes up until where it is first used. For the timeline keyframe generation
  1207. * to properly fill in the style it will place the previous value (the value from the parent
  1208. * timeline) or a default value of `*` into the backFill object. Given that each of the keyframe
  1209. * styles are objects that prototypically inhert from the backFill object, this means that if a
  1210. * value is added into the backFill then it will automatically propagate any missing values to all
  1211. * keyframes. Therefore the missing `height` value will be properly filled into the already
  1212. * processed keyframes.
  1213. *
  1214. * When a sub-timeline is created it will have its own backFill property. This is done so that
  1215. * styles present within the sub-timeline do not accidentally seep into the previous/future timeline
  1216. * keyframes
  1217. *
  1218. * (For prototypically-inherited contents to be detected a `for(i in obj)` loop must be used.)
  1219. *
  1220. * [Validation]
  1221. * The code in this file is not responsible for validation. That functionality happens with within
  1222. * the `AnimationValidatorVisitor` code.
  1223. */
  1224. function buildAnimationTimelines(driver, rootElement, ast, enterClassName, leaveClassName, startingStyles, finalStyles, options, subInstructions, errors) {
  1225. if (startingStyles === void 0) { startingStyles = {}; }
  1226. if (finalStyles === void 0) { finalStyles = {}; }
  1227. if (errors === void 0) { errors = []; }
  1228. return new AnimationTimelineBuilderVisitor().buildKeyframes(driver, rootElement, ast, enterClassName, leaveClassName, startingStyles, finalStyles, options, subInstructions, errors);
  1229. }
  1230. var AnimationTimelineBuilderVisitor = /** @class */ (function () {
  1231. function AnimationTimelineBuilderVisitor() {
  1232. }
  1233. AnimationTimelineBuilderVisitor.prototype.buildKeyframes = function (driver, rootElement, ast, enterClassName, leaveClassName, startingStyles, finalStyles, options, subInstructions, errors) {
  1234. if (errors === void 0) { errors = []; }
  1235. subInstructions = subInstructions || new ElementInstructionMap();
  1236. var context = new AnimationTimelineContext(driver, rootElement, subInstructions, enterClassName, leaveClassName, errors, []);
  1237. context.options = options;
  1238. context.currentTimeline.setStyles([startingStyles], null, context.errors, options);
  1239. visitDslNode(this, ast, context);
  1240. // this checks to see if an actual animation happened
  1241. var timelines = context.timelines.filter(function (timeline) { return timeline.containsAnimation(); });
  1242. if (timelines.length && Object.keys(finalStyles).length) {
  1243. var tl = timelines[timelines.length - 1];
  1244. if (!tl.allowOnlyTimelineStyles()) {
  1245. tl.setStyles([finalStyles], null, context.errors, options);
  1246. }
  1247. }
  1248. return timelines.length ? timelines.map(function (timeline) { return timeline.buildKeyframes(); }) :
  1249. [createTimelineInstruction(rootElement, [], [], [], 0, 0, '', false)];
  1250. };
  1251. AnimationTimelineBuilderVisitor.prototype.visitTrigger = function (ast, context) {
  1252. // these values are not visited in this AST
  1253. };
  1254. AnimationTimelineBuilderVisitor.prototype.visitState = function (ast, context) {
  1255. // these values are not visited in this AST
  1256. };
  1257. AnimationTimelineBuilderVisitor.prototype.visitTransition = function (ast, context) {
  1258. // these values are not visited in this AST
  1259. };
  1260. AnimationTimelineBuilderVisitor.prototype.visitAnimateChild = function (ast, context) {
  1261. var elementInstructions = context.subInstructions.consume(context.element);
  1262. if (elementInstructions) {
  1263. var innerContext = context.createSubContext(ast.options);
  1264. var startTime = context.currentTimeline.currentTime;
  1265. var endTime = this._visitSubInstructions(elementInstructions, innerContext, innerContext.options);
  1266. if (startTime != endTime) {
  1267. // we do this on the upper context because we created a sub context for
  1268. // the sub child animations
  1269. context.transformIntoNewTimeline(endTime);
  1270. }
  1271. }
  1272. context.previousNode = ast;
  1273. };
  1274. AnimationTimelineBuilderVisitor.prototype.visitAnimateRef = function (ast, context) {
  1275. var innerContext = context.createSubContext(ast.options);
  1276. innerContext.transformIntoNewTimeline();
  1277. this.visitReference(ast.animation, innerContext);
  1278. context.transformIntoNewTimeline(innerContext.currentTimeline.currentTime);
  1279. context.previousNode = ast;
  1280. };
  1281. AnimationTimelineBuilderVisitor.prototype._visitSubInstructions = function (instructions, context, options) {
  1282. var startTime = context.currentTimeline.currentTime;
  1283. var furthestTime = startTime;
  1284. // this is a special-case for when a user wants to skip a sub
  1285. // animation from being fired entirely.
  1286. var duration = options.duration != null ? resolveTimingValue(options.duration) : null;
  1287. var delay = options.delay != null ? resolveTimingValue(options.delay) : null;
  1288. if (duration !== 0) {
  1289. instructions.forEach(function (instruction) {
  1290. var instructionTimings = context.appendInstructionToTimeline(instruction, duration, delay);
  1291. furthestTime =
  1292. Math.max(furthestTime, instructionTimings.duration + instructionTimings.delay);
  1293. });
  1294. }
  1295. return furthestTime;
  1296. };
  1297. AnimationTimelineBuilderVisitor.prototype.visitReference = function (ast, context) {
  1298. context.updateOptions(ast.options, true);
  1299. visitDslNode(this, ast.animation, context);
  1300. context.previousNode = ast;
  1301. };
  1302. AnimationTimelineBuilderVisitor.prototype.visitSequence = function (ast, context) {
  1303. var _this = this;
  1304. var subContextCount = context.subContextCount;
  1305. var ctx = context;
  1306. var options = ast.options;
  1307. if (options && (options.params || options.delay)) {
  1308. ctx = context.createSubContext(options);
  1309. ctx.transformIntoNewTimeline();
  1310. if (options.delay != null) {
  1311. if (ctx.previousNode.type == 6 /* Style */) {
  1312. ctx.currentTimeline.snapshotCurrentStyles();
  1313. ctx.previousNode = DEFAULT_NOOP_PREVIOUS_NODE;
  1314. }
  1315. var delay = resolveTimingValue(options.delay);
  1316. ctx.delayNextStep(delay);
  1317. }
  1318. }
  1319. if (ast.steps.length) {
  1320. ast.steps.forEach(function (s) { return visitDslNode(_this, s, ctx); });
  1321. // this is here just incase the inner steps only contain or end with a style() call
  1322. ctx.currentTimeline.applyStylesToKeyframe();
  1323. // this means that some animation function within the sequence
  1324. // ended up creating a sub timeline (which means the current
  1325. // timeline cannot overlap with the contents of the sequence)
  1326. if (ctx.subContextCount > subContextCount) {
  1327. ctx.transformIntoNewTimeline();
  1328. }
  1329. }
  1330. context.previousNode = ast;
  1331. };
  1332. AnimationTimelineBuilderVisitor.prototype.visitGroup = function (ast, context) {
  1333. var _this = this;
  1334. var innerTimelines = [];
  1335. var furthestTime = context.currentTimeline.currentTime;
  1336. var delay = ast.options && ast.options.delay ? resolveTimingValue(ast.options.delay) : 0;
  1337. ast.steps.forEach(function (s) {
  1338. var innerContext = context.createSubContext(ast.options);
  1339. if (delay) {
  1340. innerContext.delayNextStep(delay);
  1341. }
  1342. visitDslNode(_this, s, innerContext);
  1343. furthestTime = Math.max(furthestTime, innerContext.currentTimeline.currentTime);
  1344. innerTimelines.push(innerContext.currentTimeline);
  1345. });
  1346. // this operation is run after the AST loop because otherwise
  1347. // if the parent timeline's collected styles were updated then
  1348. // it would pass in invalid data into the new-to-be forked items
  1349. innerTimelines.forEach(function (timeline) { return context.currentTimeline.mergeTimelineCollectedStyles(timeline); });
  1350. context.transformIntoNewTimeline(furthestTime);
  1351. context.previousNode = ast;
  1352. };
  1353. AnimationTimelineBuilderVisitor.prototype._visitTiming = function (ast, context) {
  1354. if (ast.dynamic) {
  1355. var strValue = ast.strValue;
  1356. var timingValue = context.params ? interpolateParams(strValue, context.params, context.errors) : strValue;
  1357. return resolveTiming(timingValue, context.errors);
  1358. }
  1359. else {
  1360. return { duration: ast.duration, delay: ast.delay, easing: ast.easing };
  1361. }
  1362. };
  1363. AnimationTimelineBuilderVisitor.prototype.visitAnimate = function (ast, context) {
  1364. var timings = context.currentAnimateTimings = this._visitTiming(ast.timings, context);
  1365. var timeline = context.currentTimeline;
  1366. if (timings.delay) {
  1367. context.incrementTime(timings.delay);
  1368. timeline.snapshotCurrentStyles();
  1369. }
  1370. var style = ast.style;
  1371. if (style.type == 5 /* Keyframes */) {
  1372. this.visitKeyframes(style, context);
  1373. }
  1374. else {
  1375. context.incrementTime(timings.duration);
  1376. this.visitStyle(style, context);
  1377. timeline.applyStylesToKeyframe();
  1378. }
  1379. context.currentAnimateTimings = null;
  1380. context.previousNode = ast;
  1381. };
  1382. AnimationTimelineBuilderVisitor.prototype.visitStyle = function (ast, context) {
  1383. var timeline = context.currentTimeline;
  1384. var timings = context.currentAnimateTimings;
  1385. // this is a special case for when a style() call
  1386. // directly follows an animate() call (but not inside of an animate() call)
  1387. if (!timings && timeline.getCurrentStyleProperties().length) {
  1388. timeline.forwardFrame();
  1389. }
  1390. var easing = (timings && timings.easing) || ast.easing;
  1391. if (ast.isEmptyStep) {
  1392. timeline.applyEmptyStep(easing);
  1393. }
  1394. else {
  1395. timeline.setStyles(ast.styles, easing, context.errors, context.options);
  1396. }
  1397. context.previousNode = ast;
  1398. };
  1399. AnimationTimelineBuilderVisitor.prototype.visitKeyframes = function (ast, context) {
  1400. var currentAnimateTimings = context.currentAnimateTimings;
  1401. var startTime = (context.currentTimeline).duration;
  1402. var duration = currentAnimateTimings.duration;
  1403. var innerContext = context.createSubContext();
  1404. var innerTimeline = innerContext.currentTimeline;
  1405. innerTimeline.easing = currentAnimateTimings.easing;
  1406. ast.styles.forEach(function (step) {
  1407. var offset = step.offset || 0;
  1408. innerTimeline.forwardTime(offset * duration);
  1409. innerTimeline.setStyles(step.styles, step.easing, context.errors, context.options);
  1410. innerTimeline.applyStylesToKeyframe();
  1411. });
  1412. // this will ensure that the parent timeline gets all the styles from
  1413. // the child even if the new timeline below is not used
  1414. context.currentTimeline.mergeTimelineCollectedStyles(innerTimeline);
  1415. // we do this because the window between this timeline and the sub timeline
  1416. // should ensure that the styles within are exactly the same as they were before
  1417. context.transformIntoNewTimeline(startTime + duration);
  1418. context.previousNode = ast;
  1419. };
  1420. AnimationTimelineBuilderVisitor.prototype.visitQuery = function (ast, context) {
  1421. var _this = this;
  1422. // in the event that the first step before this is a style step we need
  1423. // to ensure the styles are applied before the children are animated
  1424. var startTime = context.currentTimeline.currentTime;
  1425. var options = (ast.options || {});
  1426. var delay = options.delay ? resolveTimingValue(options.delay) : 0;
  1427. if (delay && (context.previousNode.type === 6 /* Style */ ||
  1428. (startTime == 0 && context.currentTimeline.getCurrentStyleProperties().length))) {
  1429. context.currentTimeline.snapshotCurrentStyles();
  1430. context.previousNode = DEFAULT_NOOP_PREVIOUS_NODE;
  1431. }
  1432. var furthestTime = startTime;
  1433. var elms = context.invokeQuery(ast.selector, ast.originalSelector, ast.limit, ast.includeSelf, options.optional ? true : false, context.errors);
  1434. context.currentQueryTotal = elms.length;
  1435. var sameElementTimeline = null;
  1436. elms.forEach(function (element, i) {
  1437. context.currentQueryIndex = i;
  1438. var innerContext = context.createSubContext(ast.options, element);
  1439. if (delay) {
  1440. innerContext.delayNextStep(delay);
  1441. }
  1442. if (element === context.element) {
  1443. sameElementTimeline = innerContext.currentTimeline;
  1444. }
  1445. visitDslNode(_this, ast.animation, innerContext);
  1446. // this is here just incase the inner steps only contain or end
  1447. // with a style() call (which is here to signal that this is a preparatory
  1448. // call to style an element before it is animated again)
  1449. innerContext.currentTimeline.applyStylesToKeyframe();
  1450. var endTime = innerContext.currentTimeline.currentTime;
  1451. furthestTime = Math.max(furthestTime, endTime);
  1452. });
  1453. context.currentQueryIndex = 0;
  1454. context.currentQueryTotal = 0;
  1455. context.transformIntoNewTimeline(furthestTime);
  1456. if (sameElementTimeline) {
  1457. context.currentTimeline.mergeTimelineCollectedStyles(sameElementTimeline);
  1458. context.currentTimeline.snapshotCurrentStyles();
  1459. }
  1460. context.previousNode = ast;
  1461. };
  1462. AnimationTimelineBuilderVisitor.prototype.visitStagger = function (ast, context) {
  1463. var parentContext = context.parentContext;
  1464. var tl = context.currentTimeline;
  1465. var timings = ast.timings;
  1466. var duration = Math.abs(timings.duration);
  1467. var maxTime = duration * (context.currentQueryTotal - 1);
  1468. var delay = duration * context.currentQueryIndex;
  1469. var staggerTransformer = timings.duration < 0 ? 'reverse' : timings.easing;
  1470. switch (staggerTransformer) {
  1471. case 'reverse':
  1472. delay = maxTime - delay;
  1473. break;
  1474. case 'full':
  1475. delay = parentContext.currentStaggerTime;
  1476. break;
  1477. }
  1478. var timeline = context.currentTimeline;
  1479. if (delay) {
  1480. timeline.delayNextStep(delay);
  1481. }
  1482. var startingTime = timeline.currentTime;
  1483. visitDslNode(this, ast.animation, context);
  1484. context.previousNode = ast;
  1485. // time = duration + delay
  1486. // the reason why this computation is so complex is because
  1487. // the inner timeline may either have a delay value or a stretched
  1488. // keyframe depending on if a subtimeline is not used or is used.
  1489. parentContext.currentStaggerTime =
  1490. (tl.currentTime - startingTime) + (tl.startTime - parentContext.currentTimeline.startTime);
  1491. };
  1492. return AnimationTimelineBuilderVisitor;
  1493. }());
  1494. var DEFAULT_NOOP_PREVIOUS_NODE = {};
  1495. var AnimationTimelineContext = /** @class */ (function () {
  1496. function AnimationTimelineContext(_driver, element, subInstructions, _enterClassName, _leaveClassName, errors, timelines, initialTimeline) {
  1497. this._driver = _driver;
  1498. this.element = element;
  1499. this.subInstructions = subInstructions;
  1500. this._enterClassName = _enterClassName;
  1501. this._leaveClassName = _leaveClassName;
  1502. this.errors = errors;
  1503. this.timelines = timelines;
  1504. this.parentContext = null;
  1505. this.currentAnimateTimings = null;
  1506. this.previousNode = DEFAULT_NOOP_PREVIOUS_NODE;
  1507. this.subContextCount = 0;
  1508. this.options = {};
  1509. this.currentQueryIndex = 0;
  1510. this.currentQueryTotal = 0;
  1511. this.currentStaggerTime = 0;
  1512. this.currentTimeline = initialTimeline || new TimelineBuilder(this._driver, element, 0);
  1513. timelines.push(this.currentTimeline);
  1514. }
  1515. Object.defineProperty(AnimationTimelineContext.prototype, "params", {
  1516. get: function () { return this.options.params; },
  1517. enumerable: true,
  1518. configurable: true
  1519. });
  1520. AnimationTimelineContext.prototype.updateOptions = function (options, skipIfExists) {
  1521. var _this = this;
  1522. if (!options)
  1523. return;
  1524. var newOptions = options;
  1525. var optionsToUpdate = this.options;
  1526. // NOTE: this will get patched up when other animation methods support duration overrides
  1527. if (newOptions.duration != null) {
  1528. optionsToUpdate.duration = resolveTimingValue(newOptions.duration);
  1529. }
  1530. if (newOptions.delay != null) {
  1531. optionsToUpdate.delay = resolveTimingValue(newOptions.delay);
  1532. }
  1533. var newParams = newOptions.params;
  1534. if (newParams) {
  1535. var paramsToUpdate_1 = optionsToUpdate.params;
  1536. if (!paramsToUpdate_1) {
  1537. paramsToUpdate_1 = this.options.params = {};
  1538. }
  1539. Object.keys(newParams).forEach(function (name) {
  1540. if (!skipIfExists || !paramsToUpdate_1.hasOwnProperty(name)) {
  1541. paramsToUpdate_1[name] = interpolateParams(newParams[name], paramsToUpdate_1, _this.errors);
  1542. }
  1543. });
  1544. }
  1545. };
  1546. AnimationTimelineContext.prototype._copyOptions = function () {
  1547. var options = {};
  1548. if (this.options) {
  1549. var oldParams_1 = this.options.params;
  1550. if (oldParams_1) {
  1551. var params_1 = options['params'] = {};
  1552. Object.keys(oldParams_1).forEach(function (name) { params_1[name] = oldParams_1[name]; });
  1553. }
  1554. }
  1555. return options;
  1556. };
  1557. AnimationTimelineContext.prototype.createSubContext = function (options, element, newTime) {
  1558. if (options === void 0) { options = null; }
  1559. var target = element || this.element;
  1560. var context = new AnimationTimelineContext(this._driver, target, this.subInstructions, this._enterClassName, this._leaveClassName, this.errors, this.timelines, this.currentTimeline.fork(target, newTime || 0));
  1561. context.previousNode = this.previousNode;
  1562. context.currentAnimateTimings = this.currentAnimateTimings;
  1563. context.options = this._copyOptions();
  1564. context.updateOptions(options);
  1565. context.currentQueryIndex = this.currentQueryIndex;
  1566. context.currentQueryTotal = this.currentQueryTotal;
  1567. context.parentContext = this;
  1568. this.subContextCount++;
  1569. return context;
  1570. };
  1571. AnimationTimelineContext.prototype.transformIntoNewTimeline = function (newTime) {
  1572. this.previousNode = DEFAULT_NOOP_PREVIOUS_NODE;
  1573. this.currentTimeline = this.currentTimeline.fork(this.element, newTime);
  1574. this.timelines.push(this.currentTimeline);
  1575. return this.currentTimeline;
  1576. };
  1577. AnimationTimelineContext.prototype.appendInstructionToTimeline = function (instruction, duration, delay) {
  1578. var updatedTimings = {
  1579. duration: duration != null ? duration : instruction.duration,
  1580. delay: this.currentTimeline.currentTime + (delay != null ? delay : 0) + instruction.delay,
  1581. easing: ''
  1582. };
  1583. var builder = new SubTimelineBuilder(this._driver, instruction.element, instruction.keyframes, instruction.preStyleProps, instruction.postStyleProps, updatedTimings, instruction.stretchStartingKeyframe);
  1584. this.timelines.push(builder);
  1585. return updatedTimings;
  1586. };
  1587. AnimationTimelineContext.prototype.incrementTime = function (time) {
  1588. this.currentTimeline.forwardTime(this.currentTimeline.duration + time);
  1589. };
  1590. AnimationTimelineContext.prototype.delayNextStep = function (delay) {
  1591. // negative delays are not yet supported
  1592. if (delay > 0) {
  1593. this.currentTimeline.delayNextStep(delay);
  1594. }
  1595. };
  1596. AnimationTimelineContext.prototype.invokeQuery = function (selector, originalSelector, limit, includeSelf, optional, errors) {
  1597. var results = [];
  1598. if (includeSelf) {
  1599. results.push(this.element);
  1600. }
  1601. if (selector.length > 0) { // if :self is only used then the selector is empty
  1602. selector = selector.replace(ENTER_TOKEN_REGEX, '.' + this._enterClassName);
  1603. selector = selector.replace(LEAVE_TOKEN_REGEX, '.' + this._leaveClassName);
  1604. var multi = limit != 1;
  1605. var elements = this._driver.query(this.element, selector, multi);
  1606. if (limit !== 0) {
  1607. elements = limit < 0 ? elements.slice(elements.length + limit, elements.length) :
  1608. elements.slice(0, limit);
  1609. }
  1610. results.push.apply(results, __spread(elements));
  1611. }
  1612. if (!optional && results.length == 0) {
  1613. errors.push("`query(\"" + originalSelector + "\")` returned zero elements. (Use `query(\"" + originalSelector + "\", { optional: true })` if you wish to allow this.)");
  1614. }
  1615. return results;
  1616. };
  1617. return AnimationTimelineContext;
  1618. }());
  1619. var TimelineBuilder = /** @class */ (function () {
  1620. function TimelineBuilder(_driver, element, startTime, _elementTimelineStylesLookup) {
  1621. this._driver = _driver;
  1622. this.element = element;
  1623. this.startTime = startTime;
  1624. this._elementTimelineStylesLookup = _elementTimelineStylesLookup;
  1625. this.duration = 0;
  1626. this._previousKeyframe = {};
  1627. this._currentKeyframe = {};
  1628. this._keyframes = new Map();
  1629. this._styleSummary = {};
  1630. this._pendingStyles = {};
  1631. this._backFill = {};
  1632. this._currentEmptyStepKeyframe = null;
  1633. if (!this._elementTimelineStylesLookup) {
  1634. this._elementTimelineStylesLookup = new Map();
  1635. }
  1636. this._localTimelineStyles = Object.create(this._backFill, {});
  1637. this._globalTimelineStyles = this._elementTimelineStylesLookup.get(element);
  1638. if (!this._globalTimelineStyles) {
  1639. this._globalTimelineStyles = this._localTimelineStyles;
  1640. this._elementTimelineStylesLookup.set(element, this._localTimelineStyles);
  1641. }
  1642. this._loadKeyframe();
  1643. }
  1644. TimelineBuilder.prototype.containsAnimation = function () {
  1645. switch (this._keyframes.size) {
  1646. case 0:
  1647. return false;
  1648. case 1:
  1649. return this.getCurrentStyleProperties().length > 0;
  1650. default:
  1651. return true;
  1652. }
  1653. };
  1654. TimelineBuilder.prototype.getCurrentStyleProperties = function () { return Object.keys(this._currentKeyframe); };
  1655. Object.defineProperty(TimelineBuilder.prototype, "currentTime", {
  1656. get: function () { return this.startTime + this.duration; },
  1657. enumerable: true,
  1658. configurable: true
  1659. });
  1660. TimelineBuilder.prototype.delayNextStep = function (delay) {
  1661. // in the event that a style() step is placed right before a stagger()
  1662. // and that style() step is the very first style() value in the animation
  1663. // then we need to make a copy of the keyframe [0, copy, 1] so that the delay
  1664. // properly applies the style() values to work with the stagger...
  1665. var hasPreStyleStep = this._keyframes.size == 1 && Object.keys(this._pendingStyles).length;
  1666. if (this.duration || hasPreStyleStep) {
  1667. this.forwardTime(this.currentTime + delay);
  1668. if (hasPreStyleStep) {
  1669. this.snapshotCurrentStyles();
  1670. }
  1671. }
  1672. else {
  1673. this.startTime += delay;
  1674. }
  1675. };
  1676. TimelineBuilder.prototype.fork = function (element, currentTime) {
  1677. this.applyStylesToKeyframe();
  1678. return new TimelineBuilder(this._driver, element, currentTime || this.currentTime, this._elementTimelineStylesLookup);
  1679. };
  1680. TimelineBuilder.prototype._loadKeyframe = function () {
  1681. if (this._currentKeyframe) {
  1682. this._previousKeyframe = this._currentKeyframe;
  1683. }
  1684. this._currentKeyframe = this._keyframes.get(this.duration);
  1685. if (!this._currentKeyframe) {
  1686. this._currentKeyframe = Object.create(this._backFill, {});
  1687. this._keyframes.set(this.duration, this._currentKeyframe);
  1688. }
  1689. };
  1690. TimelineBuilder.prototype.forwardFrame = function () {
  1691. this.duration += ONE_FRAME_IN_MILLISECONDS;
  1692. this._loadKeyframe();
  1693. };
  1694. TimelineBuilder.prototype.forwardTime = function (time) {
  1695. this.applyStylesToKeyframe();
  1696. this.duration = time;
  1697. this._loadKeyframe();
  1698. };
  1699. TimelineBuilder.prototype._updateStyle = function (prop, value) {
  1700. this._localTimelineStyles[prop] = value;
  1701. this._globalTimelineStyles[prop] = value;
  1702. this._styleSummary[prop] = { time: this.currentTime, value: value };
  1703. };
  1704. TimelineBuilder.prototype.allowOnlyTimelineStyles = function () { return this._currentEmptyStepKeyframe !== this._currentKeyframe; };
  1705. TimelineBuilder.prototype.applyEmptyStep = function (easing) {
  1706. var _this = this;
  1707. if (easing) {
  1708. this._previousKeyframe['easing'] = easing;
  1709. }
  1710. // special case for animate(duration):
  1711. // all missing styles are filled with a `*` value then
  1712. // if any destination styles are filled in later on the same
  1713. // keyframe then they will override the overridden styles
  1714. // We use `_globalTimelineStyles` here because there may be
  1715. // styles in previous keyframes that are not present in this timeline
  1716. Object.keys(this._globalTimelineStyles).forEach(function (prop) {
  1717. _this._backFill[prop] = _this._globalTimelineStyles[prop] || AUTO_STYLE;
  1718. _this._currentKeyframe[prop] = AUTO_STYLE;
  1719. });
  1720. this._currentEmptyStepKeyframe = this._currentKeyframe;
  1721. };
  1722. TimelineBuilder.prototype.setStyles = function (input, easing, errors, options) {
  1723. var _this = this;
  1724. if (easing) {
  1725. this._previousKeyframe['easing'] = easing;
  1726. }
  1727. var params = (options && options.params) || {};
  1728. var styles = flattenStyles(input, this._globalTimelineStyles);
  1729. Object.keys(styles).forEach(function (prop) {
  1730. var val = interpolateParams(styles[prop], params, errors);
  1731. _this._pendingStyles[prop] = val;
  1732. if (!_this._localTimelineStyles.hasOwnProperty(prop)) {
  1733. _this._backFill[prop] = _this._globalTimelineStyles.hasOwnProperty(prop) ?
  1734. _this._globalTimelineStyles[prop] :
  1735. AUTO_STYLE;
  1736. }
  1737. _this._updateStyle(prop, val);
  1738. });
  1739. };
  1740. TimelineBuilder.prototype.applyStylesToKeyframe = function () {
  1741. var _this = this;
  1742. var styles = this._pendingStyles;
  1743. var props = Object.keys(styles);
  1744. if (props.length == 0)
  1745. return;
  1746. this._pendingStyles = {};
  1747. props.forEach(function (prop) {
  1748. var val = styles[prop];
  1749. _this._currentKeyframe[prop] = val;
  1750. });
  1751. Object.keys(this._localTimelineStyles).forEach(function (prop) {
  1752. if (!_this._currentKeyframe.hasOwnProperty(prop)) {
  1753. _this._currentKeyframe[prop] = _this._localTimelineStyles[prop];
  1754. }
  1755. });
  1756. };
  1757. TimelineBuilder.prototype.snapshotCurrentStyles = function () {
  1758. var _this = this;
  1759. Object.keys(this._localTimelineStyles).forEach(function (prop) {
  1760. var val = _this._localTimelineStyles[prop];
  1761. _this._pendingStyles[prop] = val;
  1762. _this._updateStyle(prop, val);
  1763. });
  1764. };
  1765. TimelineBuilder.prototype.getFinalKeyframe = function () { return this._keyframes.get(this.duration); };
  1766. Object.defineProperty(TimelineBuilder.prototype, "properties", {
  1767. get: function () {
  1768. var properties = [];
  1769. for (var prop in this._currentKeyframe) {
  1770. properties.push(prop);
  1771. }
  1772. return properties;
  1773. },
  1774. enumerable: true,
  1775. configurable: true
  1776. });
  1777. TimelineBuilder.prototype.mergeTimelineCollectedStyles = function (timeline) {
  1778. var _this = this;
  1779. Object.keys(timeline._styleSummary).forEach(function (prop) {
  1780. var details0 = _this._styleSummary[prop];
  1781. var details1 = timeline._styleSummary[prop];
  1782. if (!details0 || details1.time > details0.time) {
  1783. _this._updateStyle(prop, details1.value);
  1784. }
  1785. });
  1786. };
  1787. TimelineBuilder.prototype.buildKeyframes = function () {
  1788. var _this = this;
  1789. this.applyStylesToKeyframe();
  1790. var preStyleProps = new Set();
  1791. var postStyleProps = new Set();
  1792. var isEmpty = this._keyframes.size === 1 && this.duration === 0;
  1793. var finalKeyframes = [];
  1794. this._keyframes.forEach(function (keyframe, time) {
  1795. var finalKeyframe = copyStyles(keyframe, true);
  1796. Object.keys(finalKeyframe).forEach(function (prop) {
  1797. var value = finalKeyframe[prop];
  1798. if (value == ɵPRE_STYLE) {
  1799. preStyleProps.add(prop);
  1800. }
  1801. else if (value == AUTO_STYLE) {
  1802. postStyleProps.add(prop);
  1803. }
  1804. });
  1805. if (!isEmpty) {
  1806. finalKeyframe['offset'] = time / _this.duration;
  1807. }
  1808. finalKeyframes.push(finalKeyframe);
  1809. });
  1810. var preProps = preStyleProps.size ? iteratorToArray(preStyleProps.values()) : [];
  1811. var postProps = postStyleProps.size ? iteratorToArray(postStyleProps.values()) : [];
  1812. // special case for a 0-second animation (which is designed just to place styles onscreen)
  1813. if (isEmpty) {
  1814. var kf0 = finalKeyframes[0];
  1815. var kf1 = copyObj(kf0);
  1816. kf0['offset'] = 0;
  1817. kf1['offset'] = 1;
  1818. finalKeyframes = [kf0, kf1];
  1819. }
  1820. return createTimelineInstruction(this.element, finalKeyframes, preProps, postProps, this.duration, this.startTime, this.easing, false);
  1821. };
  1822. return TimelineBuilder;
  1823. }());
  1824. var SubTimelineBuilder = /** @class */ (function (_super) {
  1825. __extends(SubTimelineBuilder, _super);
  1826. function SubTimelineBuilder(driver, element, keyframes, preStyleProps, postStyleProps, timings, _stretchStartingKeyframe) {
  1827. if (_stretchStartingKeyframe === void 0) { _stretchStartingKeyframe = false; }
  1828. var _this = _super.call(this, driver, element, timings.delay) || this;
  1829. _this.element = element;
  1830. _this.keyframes = keyframes;
  1831. _this.preStyleProps = preStyleProps;
  1832. _this.postStyleProps = postStyleProps;
  1833. _this._stretchStartingKeyframe = _stretchStartingKeyframe;
  1834. _this.timings = { duration: timings.duration, delay: timings.delay, easing: timings.easing };
  1835. return _this;
  1836. }
  1837. SubTimelineBuilder.prototype.containsAnimation = function () { return this.keyframes.length > 1; };
  1838. SubTimelineBuilder.prototype.buildKeyframes = function () {
  1839. var keyframes = this.keyframes;
  1840. var _a = this.timings, delay = _a.delay, duration = _a.duration, easing = _a.easing;
  1841. if (this._stretchStartingKeyframe && delay) {
  1842. var newKeyframes = [];
  1843. var totalTime = duration + delay;
  1844. var startingGap = delay / totalTime;
  1845. // the original starting keyframe now starts once the delay is done
  1846. var newFirstKeyframe = copyStyles(keyframes[0], false);
  1847. newFirstKeyframe['offset'] = 0;
  1848. newKeyframes.push(newFirstKeyframe);
  1849. var oldFirstKeyframe = copyStyles(keyframes[0], false);
  1850. oldFirstKeyframe['offset'] = roundOffset(startingGap);
  1851. newKeyframes.push(oldFirstKeyframe);
  1852. /*
  1853. When the keyframe is stretched then it means that the delay before the animation
  1854. starts is gone. Instead the first keyframe is placed at the start of the animation
  1855. and it is then copied to where it starts when the original delay is over. This basically
  1856. means nothing animates during that delay, but the styles are still renderered. For this
  1857. to work the original offset values that exist in the original keyframes must be "warped"
  1858. so that they can take the new keyframe + delay into account.
  1859. delay=1000, duration=1000, keyframes = 0 .5 1
  1860. turns into
  1861. delay=0, duration=2000, keyframes = 0 .33 .66 1
  1862. */
  1863. // offsets between 1 ... n -1 are all warped by the keyframe stretch
  1864. var limit = keyframes.length - 1;
  1865. for (var i = 1; i <= limit; i++) {
  1866. var kf = copyStyles(keyframes[i], false);
  1867. var oldOffset = kf['offset'];
  1868. var timeAtKeyframe = delay + oldOffset * duration;
  1869. kf['offset'] = roundOffset(timeAtKeyframe / totalTime);
  1870. newKeyframes.push(kf);
  1871. }
  1872. // the new starting keyframe should be added at the start
  1873. duration = totalTime;
  1874. delay = 0;
  1875. easing = '';
  1876. keyframes = newKeyframes;
  1877. }
  1878. return createTimelineInstruction(this.element, keyframes, this.preStyleProps, this.postStyleProps, duration, delay, easing, true);
  1879. };
  1880. return SubTimelineBuilder;
  1881. }(TimelineBuilder));
  1882. function roundOffset(offset, decimalPoints) {
  1883. if (decimalPoints === void 0) { decimalPoints = 3; }
  1884. var mult = Math.pow(10, decimalPoints - 1);
  1885. return Math.round(offset * mult) / mult;
  1886. }
  1887. function flattenStyles(input, allStyles) {
  1888. var styles = {};
  1889. var allProperties;
  1890. input.forEach(function (token) {
  1891. if (token === '*') {
  1892. allProperties = allProperties || Object.keys(allStyles);
  1893. allProperties.forEach(function (prop) { styles[prop] = AUTO_STYLE; });
  1894. }
  1895. else {
  1896. copyStyles(token, false, styles);
  1897. }
  1898. });
  1899. return styles;
  1900. }
  1901. var Animation = /** @class */ (function () {
  1902. function Animation(_driver, input) {
  1903. this._driver = _driver;
  1904. var errors = [];
  1905. var ast = buildAnimationAst(_driver, input, errors);
  1906. if (errors.length) {
  1907. var errorMessage = "animation validation failed:\n" + errors.join("\n");
  1908. throw new Error(errorMessage);
  1909. }
  1910. this._animationAst = ast;
  1911. }
  1912. Animation.prototype.buildTimelines = function (element, startingStyles, destinationStyles, options, subInstructions) {
  1913. var start = Array.isArray(startingStyles) ? normalizeStyles(startingStyles) :
  1914. startingStyles;
  1915. var dest = Array.isArray(destinationStyles) ? normalizeStyles(destinationStyles) :
  1916. destinationStyles;
  1917. var errors = [];
  1918. subInstructions = subInstructions || new ElementInstructionMap();
  1919. var result = buildAnimationTimelines(this._driver, element, this._animationAst, ENTER_CLASSNAME, LEAVE_CLASSNAME, start, dest, options, subInstructions, errors);
  1920. if (errors.length) {
  1921. var errorMessage = "animation building failed:\n" + errors.join("\n");
  1922. throw new Error(errorMessage);
  1923. }
  1924. return result;
  1925. };
  1926. return Animation;
  1927. }());
  1928. /**
  1929. * @license
  1930. * Copyright Google Inc. All Rights Reserved.
  1931. *
  1932. * Use of this source code is governed by an MIT-style license that can be
  1933. * found in the LICENSE file at https://angular.io/license
  1934. */
  1935. /**
  1936. * @publicApi
  1937. */
  1938. var AnimationStyleNormalizer = /** @class */ (function () {
  1939. function AnimationStyleNormalizer() {
  1940. }
  1941. return AnimationStyleNormalizer;
  1942. }());
  1943. /**
  1944. * @publicApi
  1945. */
  1946. var NoopAnimationStyleNormalizer = /** @class */ (function () {
  1947. function NoopAnimationStyleNormalizer() {
  1948. }
  1949. NoopAnimationStyleNormalizer.prototype.normalizePropertyName = function (propertyName, errors) { return propertyName; };
  1950. NoopAnimationStyleNormalizer.prototype.normalizeStyleValue = function (userProvidedProperty, normalizedProperty, value, errors) {
  1951. return value;
  1952. };
  1953. return NoopAnimationStyleNormalizer;
  1954. }());
  1955. var WebAnimationsStyleNormalizer = /** @class */ (function (_super) {
  1956. __extends(WebAnimationsStyleNormalizer, _super);
  1957. function WebAnimationsStyleNormalizer() {
  1958. return _super !== null && _super.apply(this, arguments) || this;
  1959. }
  1960. WebAnimationsStyleNormalizer.prototype.normalizePropertyName = function (propertyName, errors) {
  1961. return dashCaseToCamelCase(propertyName);
  1962. };
  1963. WebAnimationsStyleNormalizer.prototype.normalizeStyleValue = function (userProvidedProperty, normalizedProperty, value, errors) {
  1964. var unit = '';
  1965. var strVal = value.toString().trim();
  1966. if (DIMENSIONAL_PROP_MAP[normalizedProperty] && value !== 0 && value !== '0') {
  1967. if (typeof value === 'number') {
  1968. unit = 'px';
  1969. }
  1970. else {
  1971. var valAndSuffixMatch = value.match(/^[+-]?[\d\.]+([a-z]*)$/);
  1972. if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) {
  1973. errors.push("Please provide a CSS unit value for " + userProvidedProperty + ":" + value);
  1974. }
  1975. }
  1976. }
  1977. return strVal + unit;
  1978. };
  1979. return WebAnimationsStyleNormalizer;
  1980. }(AnimationStyleNormalizer));
  1981. var ɵ0 = function () { return makeBooleanMap('width,height,minWidth,minHeight,maxWidth,maxHeight,left,top,bottom,right,fontSize,outlineWidth,outlineOffset,paddingTop,paddingLeft,paddingBottom,paddingRight,marginTop,marginLeft,marginBottom,marginRight,borderRadius,borderWidth,borderTopWidth,borderLeftWidth,borderRightWidth,borderBottomWidth,textIndent,perspective'
  1982. .split(',')); };
  1983. var DIMENSIONAL_PROP_MAP = (ɵ0)();
  1984. function makeBooleanMap(keys) {
  1985. var map = {};
  1986. keys.forEach(function (key) { return map[key] = true; });
  1987. return map;
  1988. }
  1989. function createTransitionInstruction(element, triggerName, fromState, toState, isRemovalTransition, fromStyles, toStyles, timelines, queriedElements, preStyleProps, postStyleProps, totalTime, errors) {
  1990. return {
  1991. type: 0 /* TransitionAnimation */,
  1992. element: element,
  1993. triggerName: triggerName,
  1994. isRemovalTransition: isRemovalTransition,
  1995. fromState: fromState,
  1996. fromStyles: fromStyles,
  1997. toState: toState,
  1998. toStyles: toStyles,
  1999. timelines: timelines,
  2000. queriedElements: queriedElements,
  2001. preStyleProps: preStyleProps,
  2002. postStyleProps: postStyleProps,
  2003. totalTime: totalTime,
  2004. errors: errors
  2005. };
  2006. }
  2007. var EMPTY_OBJECT = {};
  2008. var AnimationTransitionFactory = /** @class */ (function () {
  2009. function AnimationTransitionFactory(_triggerName, ast, _stateStyles) {
  2010. this._triggerName = _triggerName;
  2011. this.ast = ast;
  2012. this._stateStyles = _stateStyles;
  2013. }
  2014. AnimationTransitionFactory.prototype.match = function (currentState, nextState, element, params) {
  2015. return oneOrMoreTransitionsMatch(this.ast.matchers, currentState, nextState, element, params);
  2016. };
  2017. AnimationTransitionFactory.prototype.buildStyles = function (stateName, params, errors) {
  2018. var backupStateStyler = this._stateStyles['*'];
  2019. var stateStyler = this._stateStyles[stateName];
  2020. var backupStyles = backupStateStyler ? backupStateStyler.buildStyles(params, errors) : {};
  2021. return stateStyler ? stateStyler.buildStyles(params, errors) : backupStyles;
  2022. };
  2023. AnimationTransitionFactory.prototype.build = function (driver, element, currentState, nextState, enterClassName, leaveClassName, currentOptions, nextOptions, subInstructions, skipAstBuild) {
  2024. var errors = [];
  2025. var transitionAnimationParams = this.ast.options && this.ast.options.params || EMPTY_OBJECT;
  2026. var currentAnimationParams = currentOptions && currentOptions.params || EMPTY_OBJECT;
  2027. var currentStateStyles = this.buildStyles(currentState, currentAnimationParams, errors);
  2028. var nextAnimationParams = nextOptions && nextOptions.params || EMPTY_OBJECT;
  2029. var nextStateStyles = this.buildStyles(nextState, nextAnimationParams, errors);
  2030. var queriedElements = new Set();
  2031. var preStyleMap = new Map();
  2032. var postStyleMap = new Map();
  2033. var isRemoval = nextState === 'void';
  2034. var animationOptions = { params: __assign({}, transitionAnimationParams, nextAnimationParams) };
  2035. var timelines = skipAstBuild ? [] : buildAnimationTimelines(driver, element, this.ast.animation, enterClassName, leaveClassName, currentStateStyles, nextStateStyles, animationOptions, subInstructions, errors);
  2036. var totalTime = 0;
  2037. timelines.forEach(function (tl) { totalTime = Math.max(tl.duration + tl.delay, totalTime); });
  2038. if (errors.length) {
  2039. return createTransitionInstruction(element, this._triggerName, currentState, nextState, isRemoval, currentStateStyles, nextStateStyles, [], [], preStyleMap, postStyleMap, totalTime, errors);
  2040. }
  2041. timelines.forEach(function (tl) {
  2042. var elm = tl.element;
  2043. var preProps = getOrSetAsInMap(preStyleMap, elm, {});
  2044. tl.preStyleProps.forEach(function (prop) { return preProps[prop] = true; });
  2045. var postProps = getOrSetAsInMap(postStyleMap, elm, {});
  2046. tl.postStyleProps.forEach(function (prop) { return postProps[prop] = true; });
  2047. if (elm !== element) {
  2048. queriedElements.add(elm);
  2049. }
  2050. });
  2051. var queriedElementsList = iteratorToArray(queriedElements.values());
  2052. return createTransitionInstruction(element, this._triggerName, currentState, nextState, isRemoval, currentStateStyles, nextStateStyles, timelines, queriedElementsList, preStyleMap, postStyleMap, totalTime);
  2053. };
  2054. return AnimationTransitionFactory;
  2055. }());
  2056. function oneOrMoreTransitionsMatch(matchFns, currentState, nextState, element, params) {
  2057. return matchFns.some(function (fn) { return fn(currentState, nextState, element, params); });
  2058. }
  2059. var AnimationStateStyles = /** @class */ (function () {
  2060. function AnimationStateStyles(styles, defaultParams) {
  2061. this.styles = styles;
  2062. this.defaultParams = defaultParams;
  2063. }
  2064. AnimationStateStyles.prototype.buildStyles = function (params, errors) {
  2065. var finalStyles = {};
  2066. var combinedParams = copyObj(this.defaultParams);
  2067. Object.keys(params).forEach(function (key) {
  2068. var value = params[key];
  2069. if (value != null) {
  2070. combinedParams[key] = value;
  2071. }
  2072. });
  2073. this.styles.styles.forEach(function (value) {
  2074. if (typeof value !== 'string') {
  2075. var styleObj_1 = value;
  2076. Object.keys(styleObj_1).forEach(function (prop) {
  2077. var val = styleObj_1[prop];
  2078. if (val.length > 1) {
  2079. val = interpolateParams(val, combinedParams, errors);
  2080. }
  2081. finalStyles[prop] = val;
  2082. });
  2083. }
  2084. });
  2085. return finalStyles;
  2086. };
  2087. return AnimationStateStyles;
  2088. }());
  2089. /**
  2090. * @publicApi
  2091. */
  2092. function buildTrigger(name, ast) {
  2093. return new AnimationTrigger(name, ast);
  2094. }
  2095. /**
  2096. * @publicApi
  2097. */
  2098. var AnimationTrigger = /** @class */ (function () {
  2099. function AnimationTrigger(name, ast) {
  2100. var _this = this;
  2101. this.name = name;
  2102. this.ast = ast;
  2103. this.transitionFactories = [];
  2104. this.states = {};
  2105. ast.states.forEach(function (ast) {
  2106. var defaultParams = (ast.options && ast.options.params) || {};
  2107. _this.states[ast.name] = new AnimationStateStyles(ast.style, defaultParams);
  2108. });
  2109. balanceProperties(this.states, 'true', '1');
  2110. balanceProperties(this.states, 'false', '0');
  2111. ast.transitions.forEach(function (ast) {
  2112. _this.transitionFactories.push(new AnimationTransitionFactory(name, ast, _this.states));
  2113. });
  2114. this.fallbackTransition = createFallbackTransition(name, this.states);
  2115. }
  2116. Object.defineProperty(AnimationTrigger.prototype, "containsQueries", {
  2117. get: function () { return this.ast.queryCount > 0; },
  2118. enumerable: true,
  2119. configurable: true
  2120. });
  2121. AnimationTrigger.prototype.matchTransition = function (currentState, nextState, element, params) {
  2122. var entry = this.transitionFactories.find(function (f) { return f.match(currentState, nextState, element, params); });
  2123. return entry || null;
  2124. };
  2125. AnimationTrigger.prototype.matchStyles = function (currentState, params, errors) {
  2126. return this.fallbackTransition.buildStyles(currentState, params, errors);
  2127. };
  2128. return AnimationTrigger;
  2129. }());
  2130. function createFallbackTransition(triggerName, states) {
  2131. var matchers = [function (fromState, toState) { return true; }];
  2132. var animation = { type: 2 /* Sequence */, steps: [], options: null };
  2133. var transition = {
  2134. type: 1 /* Transition */,
  2135. animation: animation,
  2136. matchers: matchers,
  2137. options: null,
  2138. queryCount: 0,
  2139. depCount: 0
  2140. };
  2141. return new AnimationTransitionFactory(triggerName, transition, states);
  2142. }
  2143. function balanceProperties(obj, key1, key2) {
  2144. if (obj.hasOwnProperty(key1)) {
  2145. if (!obj.hasOwnProperty(key2)) {
  2146. obj[key2] = obj[key1];
  2147. }
  2148. }
  2149. else if (obj.hasOwnProperty(key2)) {
  2150. obj[key1] = obj[key2];
  2151. }
  2152. }
  2153. /**
  2154. * @license
  2155. * Copyright Google Inc. All Rights Reserved.
  2156. *
  2157. * Use of this source code is governed by an MIT-style license that can be
  2158. * found in the LICENSE file at https://angular.io/license
  2159. */
  2160. var EMPTY_INSTRUCTION_MAP = new ElementInstructionMap();
  2161. var TimelineAnimationEngine = /** @class */ (function () {
  2162. function TimelineAnimationEngine(bodyNode, _driver, _normalizer) {
  2163. this.bodyNode = bodyNode;
  2164. this._driver = _driver;
  2165. this._normalizer = _normalizer;
  2166. this._animations = {};
  2167. this._playersById = {};
  2168. this.players = [];
  2169. }
  2170. TimelineAnimationEngine.prototype.register = function (id, metadata) {
  2171. var errors = [];
  2172. var ast = buildAnimationAst(this._driver, metadata, errors);
  2173. if (errors.length) {
  2174. throw new Error("Unable to build the animation due to the following errors: " + errors.join("\n"));
  2175. }
  2176. else {
  2177. this._animations[id] = ast;
  2178. }
  2179. };
  2180. TimelineAnimationEngine.prototype._buildPlayer = function (i, preStyles, postStyles) {
  2181. var element = i.element;
  2182. var keyframes = normalizeKeyframes(this._driver, this._normalizer, element, i.keyframes, preStyles, postStyles);
  2183. return this._driver.animate(element, keyframes, i.duration, i.delay, i.easing, [], true);
  2184. };
  2185. TimelineAnimationEngine.prototype.create = function (id, element, options) {
  2186. var _this = this;
  2187. if (options === void 0) { options = {}; }
  2188. var errors = [];
  2189. var ast = this._animations[id];
  2190. var instructions;
  2191. var autoStylesMap = new Map();
  2192. if (ast) {
  2193. instructions = buildAnimationTimelines(this._driver, element, ast, ENTER_CLASSNAME, LEAVE_CLASSNAME, {}, {}, options, EMPTY_INSTRUCTION_MAP, errors);
  2194. instructions.forEach(function (inst) {
  2195. var styles = getOrSetAsInMap(autoStylesMap, inst.element, {});
  2196. inst.postStyleProps.forEach(function (prop) { return styles[prop] = null; });
  2197. });
  2198. }
  2199. else {
  2200. errors.push('The requested animation doesn\'t exist or has already been destroyed');
  2201. instructions = [];
  2202. }
  2203. if (errors.length) {
  2204. throw new Error("Unable to create the animation due to the following errors: " + errors.join("\n"));
  2205. }
  2206. autoStylesMap.forEach(function (styles, element) {
  2207. Object.keys(styles).forEach(function (prop) { styles[prop] = _this._driver.computeStyle(element, prop, AUTO_STYLE); });
  2208. });
  2209. var players = instructions.map(function (i) {
  2210. var styles = autoStylesMap.get(i.element);
  2211. return _this._buildPlayer(i, {}, styles);
  2212. });
  2213. var player = optimizeGroupPlayer(players);
  2214. this._playersById[id] = player;
  2215. player.onDestroy(function () { return _this.destroy(id); });
  2216. this.players.push(player);
  2217. return player;
  2218. };
  2219. TimelineAnimationEngine.prototype.destroy = function (id) {
  2220. var player = this._getPlayer(id);
  2221. player.destroy();
  2222. delete this._playersById[id];
  2223. var index = this.players.indexOf(player);
  2224. if (index >= 0) {
  2225. this.players.splice(index, 1);
  2226. }
  2227. };
  2228. TimelineAnimationEngine.prototype._getPlayer = function (id) {
  2229. var player = this._playersById[id];
  2230. if (!player) {
  2231. throw new Error("Unable to find the timeline player referenced by " + id);
  2232. }
  2233. return player;
  2234. };
  2235. TimelineAnimationEngine.prototype.listen = function (id, element, eventName, callback) {
  2236. // triggerName, fromState, toState are all ignored for timeline animations
  2237. var baseEvent = makeAnimationEvent(element, '', '', '');
  2238. listenOnPlayer(this._getPlayer(id), eventName, baseEvent, callback);
  2239. return function () { };
  2240. };
  2241. TimelineAnimationEngine.prototype.command = function (id, element, command, args) {
  2242. if (command == 'register') {
  2243. this.register(id, args[0]);
  2244. return;
  2245. }
  2246. if (command == 'create') {
  2247. var options = (args[0] || {});
  2248. this.create(id, element, options);
  2249. return;
  2250. }
  2251. var player = this._getPlayer(id);
  2252. switch (command) {
  2253. case 'play':
  2254. player.play();
  2255. break;
  2256. case 'pause':
  2257. player.pause();
  2258. break;
  2259. case 'reset':
  2260. player.reset();
  2261. break;
  2262. case 'restart':
  2263. player.restart();
  2264. break;
  2265. case 'finish':
  2266. player.finish();
  2267. break;
  2268. case 'init':
  2269. player.init();
  2270. break;
  2271. case 'setPosition':
  2272. player.setPosition(parseFloat(args[0]));
  2273. break;
  2274. case 'destroy':
  2275. this.destroy(id);
  2276. break;
  2277. }
  2278. };
  2279. return TimelineAnimationEngine;
  2280. }());
  2281. var QUEUED_CLASSNAME = 'ng-animate-queued';
  2282. var QUEUED_SELECTOR = '.ng-animate-queued';
  2283. var DISABLED_CLASSNAME = 'ng-animate-disabled';
  2284. var DISABLED_SELECTOR = '.ng-animate-disabled';
  2285. var STAR_CLASSNAME = 'ng-star-inserted';
  2286. var STAR_SELECTOR = '.ng-star-inserted';
  2287. var EMPTY_PLAYER_ARRAY = [];
  2288. var NULL_REMOVAL_STATE = {
  2289. namespaceId: '',
  2290. setForRemoval: false,
  2291. setForMove: false,
  2292. hasAnimation: false,
  2293. removedBeforeQueried: false
  2294. };
  2295. var NULL_REMOVED_QUERIED_STATE = {
  2296. namespaceId: '',
  2297. setForMove: false,
  2298. setForRemoval: false,
  2299. hasAnimation: false,
  2300. removedBeforeQueried: true
  2301. };
  2302. var REMOVAL_FLAG = '__ng_removed';
  2303. var StateValue = /** @class */ (function () {
  2304. function StateValue(input, namespaceId) {
  2305. if (namespaceId === void 0) { namespaceId = ''; }
  2306. this.namespaceId = namespaceId;
  2307. var isObj = input && input.hasOwnProperty('value');
  2308. var value = isObj ? input['value'] : input;
  2309. this.value = normalizeTriggerValue(value);
  2310. if (isObj) {
  2311. var options = copyObj(input);
  2312. delete options['value'];
  2313. this.options = options;
  2314. }
  2315. else {
  2316. this.options = {};
  2317. }
  2318. if (!this.options.params) {
  2319. this.options.params = {};
  2320. }
  2321. }
  2322. Object.defineProperty(StateValue.prototype, "params", {
  2323. get: function () { return this.options.params; },
  2324. enumerable: true,
  2325. configurable: true
  2326. });
  2327. StateValue.prototype.absorbOptions = function (options) {
  2328. var newParams = options.params;
  2329. if (newParams) {
  2330. var oldParams_1 = this.options.params;
  2331. Object.keys(newParams).forEach(function (prop) {
  2332. if (oldParams_1[prop] == null) {
  2333. oldParams_1[prop] = newParams[prop];
  2334. }
  2335. });
  2336. }
  2337. };
  2338. return StateValue;
  2339. }());
  2340. var VOID_VALUE = 'void';
  2341. var DEFAULT_STATE_VALUE = new StateValue(VOID_VALUE);
  2342. var AnimationTransitionNamespace = /** @class */ (function () {
  2343. function AnimationTransitionNamespace(id, hostElement, _engine) {
  2344. this.id = id;
  2345. this.hostElement = hostElement;
  2346. this._engine = _engine;
  2347. this.players = [];
  2348. this._triggers = {};
  2349. this._queue = [];
  2350. this._elementListeners = new Map();
  2351. this._hostClassName = 'ng-tns-' + id;
  2352. addClass(hostElement, this._hostClassName);
  2353. }
  2354. AnimationTransitionNamespace.prototype.listen = function (element, name, phase, callback) {
  2355. var _this = this;
  2356. if (!this._triggers.hasOwnProperty(name)) {
  2357. throw new Error("Unable to listen on the animation trigger event \"" + phase + "\" because the animation trigger \"" + name + "\" doesn't exist!");
  2358. }
  2359. if (phase == null || phase.length == 0) {
  2360. throw new Error("Unable to listen on the animation trigger \"" + name + "\" because the provided event is undefined!");
  2361. }
  2362. if (!isTriggerEventValid(phase)) {
  2363. throw new Error("The provided animation trigger event \"" + phase + "\" for the animation trigger \"" + name + "\" is not supported!");
  2364. }
  2365. var listeners = getOrSetAsInMap(this._elementListeners, element, []);
  2366. var data = { name: name, phase: phase, callback: callback };
  2367. listeners.push(data);
  2368. var triggersWithStates = getOrSetAsInMap(this._engine.statesByElement, element, {});
  2369. if (!triggersWithStates.hasOwnProperty(name)) {
  2370. addClass(element, NG_TRIGGER_CLASSNAME);
  2371. addClass(element, NG_TRIGGER_CLASSNAME + '-' + name);
  2372. triggersWithStates[name] = DEFAULT_STATE_VALUE;
  2373. }
  2374. return function () {
  2375. // the event listener is removed AFTER the flush has occurred such
  2376. // that leave animations callbacks can fire (otherwise if the node
  2377. // is removed in between then the listeners would be deregistered)
  2378. _this._engine.afterFlush(function () {
  2379. var index = listeners.indexOf(data);
  2380. if (index >= 0) {
  2381. listeners.splice(index, 1);
  2382. }
  2383. if (!_this._triggers[name]) {
  2384. delete triggersWithStates[name];
  2385. }
  2386. });
  2387. };
  2388. };
  2389. AnimationTransitionNamespace.prototype.register = function (name, ast) {
  2390. if (this._triggers[name]) {
  2391. // throw
  2392. return false;
  2393. }
  2394. else {
  2395. this._triggers[name] = ast;
  2396. return true;
  2397. }
  2398. };
  2399. AnimationTransitionNamespace.prototype._getTrigger = function (name) {
  2400. var trigger = this._triggers[name];
  2401. if (!trigger) {
  2402. throw new Error("The provided animation trigger \"" + name + "\" has not been registered!");
  2403. }
  2404. return trigger;
  2405. };
  2406. AnimationTransitionNamespace.prototype.trigger = function (element, triggerName, value, defaultToFallback) {
  2407. var _this = this;
  2408. if (defaultToFallback === void 0) { defaultToFallback = true; }
  2409. var trigger = this._getTrigger(triggerName);
  2410. var player = new TransitionAnimationPlayer(this.id, triggerName, element);
  2411. var triggersWithStates = this._engine.statesByElement.get(element);
  2412. if (!triggersWithStates) {
  2413. addClass(element, NG_TRIGGER_CLASSNAME);
  2414. addClass(element, NG_TRIGGER_CLASSNAME + '-' + triggerName);
  2415. this._engine.statesByElement.set(element, triggersWithStates = {});
  2416. }
  2417. var fromState = triggersWithStates[triggerName];
  2418. var toState = new StateValue(value, this.id);
  2419. var isObj = value && value.hasOwnProperty('value');
  2420. if (!isObj && fromState) {
  2421. toState.absorbOptions(fromState.options);
  2422. }
  2423. triggersWithStates[triggerName] = toState;
  2424. if (!fromState) {
  2425. fromState = DEFAULT_STATE_VALUE;
  2426. }
  2427. var isRemoval = toState.value === VOID_VALUE;
  2428. // normally this isn't reached by here, however, if an object expression
  2429. // is passed in then it may be a new object each time. Comparing the value
  2430. // is important since that will stay the same despite there being a new object.
  2431. // The removal arc here is special cased because the same element is triggered
  2432. // twice in the event that it contains animations on the outer/inner portions
  2433. // of the host container
  2434. if (!isRemoval && fromState.value === toState.value) {
  2435. // this means that despite the value not changing, some inner params
  2436. // have changed which means that the animation final styles need to be applied
  2437. if (!objEquals(fromState.params, toState.params)) {
  2438. var errors = [];
  2439. var fromStyles_1 = trigger.matchStyles(fromState.value, fromState.params, errors);
  2440. var toStyles_1 = trigger.matchStyles(toState.value, toState.params, errors);
  2441. if (errors.length) {
  2442. this._engine.reportError(errors);
  2443. }
  2444. else {
  2445. this._engine.afterFlush(function () {
  2446. eraseStyles(element, fromStyles_1);
  2447. setStyles(element, toStyles_1);
  2448. });
  2449. }
  2450. }
  2451. return;
  2452. }
  2453. var playersOnElement = getOrSetAsInMap(this._engine.playersByElement, element, []);
  2454. playersOnElement.forEach(function (player) {
  2455. // only remove the player if it is queued on the EXACT same trigger/namespace
  2456. // we only also deal with queued players here because if the animation has
  2457. // started then we want to keep the player alive until the flush happens
  2458. // (which is where the previousPlayers are passed into the new palyer)
  2459. if (player.namespaceId == _this.id && player.triggerName == triggerName && player.queued) {
  2460. player.destroy();
  2461. }
  2462. });
  2463. var transition = trigger.matchTransition(fromState.value, toState.value, element, toState.params);
  2464. var isFallbackTransition = false;
  2465. if (!transition) {
  2466. if (!defaultToFallback)
  2467. return;
  2468. transition = trigger.fallbackTransition;
  2469. isFallbackTransition = true;
  2470. }
  2471. this._engine.totalQueuedPlayers++;
  2472. this._queue.push({ element: element, triggerName: triggerName, transition: transition, fromState: fromState, toState: toState, player: player, isFallbackTransition: isFallbackTransition });
  2473. if (!isFallbackTransition) {
  2474. addClass(element, QUEUED_CLASSNAME);
  2475. player.onStart(function () { removeClass(element, QUEUED_CLASSNAME); });
  2476. }
  2477. player.onDone(function () {
  2478. var index = _this.players.indexOf(player);
  2479. if (index >= 0) {
  2480. _this.players.splice(index, 1);
  2481. }
  2482. var players = _this._engine.playersByElement.get(element);
  2483. if (players) {
  2484. var index_1 = players.indexOf(player);
  2485. if (index_1 >= 0) {
  2486. players.splice(index_1, 1);
  2487. }
  2488. }
  2489. });
  2490. this.players.push(player);
  2491. playersOnElement.push(player);
  2492. return player;
  2493. };
  2494. AnimationTransitionNamespace.prototype.deregister = function (name) {
  2495. var _this = this;
  2496. delete this._triggers[name];
  2497. this._engine.statesByElement.forEach(function (stateMap, element) { delete stateMap[name]; });
  2498. this._elementListeners.forEach(function (listeners, element) {
  2499. _this._elementListeners.set(element, listeners.filter(function (entry) { return entry.name != name; }));
  2500. });
  2501. };
  2502. AnimationTransitionNamespace.prototype.clearElementCache = function (element) {
  2503. this._engine.statesByElement.delete(element);
  2504. this._elementListeners.delete(element);
  2505. var elementPlayers = this._engine.playersByElement.get(element);
  2506. if (elementPlayers) {
  2507. elementPlayers.forEach(function (player) { return player.destroy(); });
  2508. this._engine.playersByElement.delete(element);
  2509. }
  2510. };
  2511. AnimationTransitionNamespace.prototype._signalRemovalForInnerTriggers = function (rootElement, context, animate) {
  2512. var _this = this;
  2513. if (animate === void 0) { animate = false; }
  2514. // emulate a leave animation for all inner nodes within this node.
  2515. // If there are no animations found for any of the nodes then clear the cache
  2516. // for the element.
  2517. this._engine.driver.query(rootElement, NG_TRIGGER_SELECTOR, true).forEach(function (elm) {
  2518. // this means that an inner remove() operation has already kicked off
  2519. // the animation on this element...
  2520. if (elm[REMOVAL_FLAG])
  2521. return;
  2522. var namespaces = _this._engine.fetchNamespacesByElement(elm);
  2523. if (namespaces.size) {
  2524. namespaces.forEach(function (ns) { return ns.triggerLeaveAnimation(elm, context, false, true); });
  2525. }
  2526. else {
  2527. _this.clearElementCache(elm);
  2528. }
  2529. });
  2530. };
  2531. AnimationTransitionNamespace.prototype.triggerLeaveAnimation = function (element, context, destroyAfterComplete, defaultToFallback) {
  2532. var _this = this;
  2533. var triggerStates = this._engine.statesByElement.get(element);
  2534. if (triggerStates) {
  2535. var players_1 = [];
  2536. Object.keys(triggerStates).forEach(function (triggerName) {
  2537. // this check is here in the event that an element is removed
  2538. // twice (both on the host level and the component level)
  2539. if (_this._triggers[triggerName]) {
  2540. var player = _this.trigger(element, triggerName, VOID_VALUE, defaultToFallback);
  2541. if (player) {
  2542. players_1.push(player);
  2543. }
  2544. }
  2545. });
  2546. if (players_1.length) {
  2547. this._engine.markElementAsRemoved(this.id, element, true, context);
  2548. if (destroyAfterComplete) {
  2549. optimizeGroupPlayer(players_1).onDone(function () { return _this._engine.processLeaveNode(element); });
  2550. }
  2551. return true;
  2552. }
  2553. }
  2554. return false;
  2555. };
  2556. AnimationTransitionNamespace.prototype.prepareLeaveAnimationListeners = function (element) {
  2557. var _this = this;
  2558. var listeners = this._elementListeners.get(element);
  2559. if (listeners) {
  2560. var visitedTriggers_1 = new Set();
  2561. listeners.forEach(function (listener) {
  2562. var triggerName = listener.name;
  2563. if (visitedTriggers_1.has(triggerName))
  2564. return;
  2565. visitedTriggers_1.add(triggerName);
  2566. var trigger = _this._triggers[triggerName];
  2567. var transition = trigger.fallbackTransition;
  2568. var elementStates = _this._engine.statesByElement.get(element);
  2569. var fromState = elementStates[triggerName] || DEFAULT_STATE_VALUE;
  2570. var toState = new StateValue(VOID_VALUE);
  2571. var player = new TransitionAnimationPlayer(_this.id, triggerName, element);
  2572. _this._engine.totalQueuedPlayers++;
  2573. _this._queue.push({
  2574. element: element,
  2575. triggerName: triggerName,
  2576. transition: transition,
  2577. fromState: fromState,
  2578. toState: toState,
  2579. player: player,
  2580. isFallbackTransition: true
  2581. });
  2582. });
  2583. }
  2584. };
  2585. AnimationTransitionNamespace.prototype.removeNode = function (element, context) {
  2586. var _this = this;
  2587. var engine = this._engine;
  2588. if (element.childElementCount) {
  2589. this._signalRemovalForInnerTriggers(element, context, true);
  2590. }
  2591. // this means that a * => VOID animation was detected and kicked off
  2592. if (this.triggerLeaveAnimation(element, context, true))
  2593. return;
  2594. // find the player that is animating and make sure that the
  2595. // removal is delayed until that player has completed
  2596. var containsPotentialParentTransition = false;
  2597. if (engine.totalAnimations) {
  2598. var currentPlayers = engine.players.length ? engine.playersByQueriedElement.get(element) : [];
  2599. // when this `if statement` does not continue forward it means that
  2600. // a previous animation query has selected the current element and
  2601. // is animating it. In this situation want to continue forwards and
  2602. // allow the element to be queued up for animation later.
  2603. if (currentPlayers && currentPlayers.length) {
  2604. containsPotentialParentTransition = true;
  2605. }
  2606. else {
  2607. var parent_1 = element;
  2608. while (parent_1 = parent_1.parentNode) {
  2609. var triggers = engine.statesByElement.get(parent_1);
  2610. if (triggers) {
  2611. containsPotentialParentTransition = true;
  2612. break;
  2613. }
  2614. }
  2615. }
  2616. }
  2617. // at this stage we know that the element will either get removed
  2618. // during flush or will be picked up by a parent query. Either way
  2619. // we need to fire the listeners for this element when it DOES get
  2620. // removed (once the query parent animation is done or after flush)
  2621. this.prepareLeaveAnimationListeners(element);
  2622. // whether or not a parent has an animation we need to delay the deferral of the leave
  2623. // operation until we have more information (which we do after flush() has been called)
  2624. if (containsPotentialParentTransition) {
  2625. engine.markElementAsRemoved(this.id, element, false, context);
  2626. }
  2627. else {
  2628. // we do this after the flush has occurred such
  2629. // that the callbacks can be fired
  2630. engine.afterFlush(function () { return _this.clearElementCache(element); });
  2631. engine.destroyInnerAnimations(element);
  2632. engine._onRemovalComplete(element, context);
  2633. }
  2634. };
  2635. AnimationTransitionNamespace.prototype.insertNode = function (element, parent) { addClass(element, this._hostClassName); };
  2636. AnimationTransitionNamespace.prototype.drainQueuedTransitions = function (microtaskId) {
  2637. var _this = this;
  2638. var instructions = [];
  2639. this._queue.forEach(function (entry) {
  2640. var player = entry.player;
  2641. if (player.destroyed)
  2642. return;
  2643. var element = entry.element;
  2644. var listeners = _this._elementListeners.get(element);
  2645. if (listeners) {
  2646. listeners.forEach(function (listener) {
  2647. if (listener.name == entry.triggerName) {
  2648. var baseEvent = makeAnimationEvent(element, entry.triggerName, entry.fromState.value, entry.toState.value);
  2649. baseEvent['_data'] = microtaskId;
  2650. listenOnPlayer(entry.player, listener.phase, baseEvent, listener.callback);
  2651. }
  2652. });
  2653. }
  2654. if (player.markedForDestroy) {
  2655. _this._engine.afterFlush(function () {
  2656. // now we can destroy the element properly since the event listeners have
  2657. // been bound to the player
  2658. player.destroy();
  2659. });
  2660. }
  2661. else {
  2662. instructions.push(entry);
  2663. }
  2664. });
  2665. this._queue = [];
  2666. return instructions.sort(function (a, b) {
  2667. // if depCount == 0 them move to front
  2668. // otherwise if a contains b then move back
  2669. var d0 = a.transition.ast.depCount;
  2670. var d1 = b.transition.ast.depCount;
  2671. if (d0 == 0 || d1 == 0) {
  2672. return d0 - d1;
  2673. }
  2674. return _this._engine.driver.containsElement(a.element, b.element) ? 1 : -1;
  2675. });
  2676. };
  2677. AnimationTransitionNamespace.prototype.destroy = function (context) {
  2678. this.players.forEach(function (p) { return p.destroy(); });
  2679. this._signalRemovalForInnerTriggers(this.hostElement, context);
  2680. };
  2681. AnimationTransitionNamespace.prototype.elementContainsData = function (element) {
  2682. var containsData = false;
  2683. if (this._elementListeners.has(element))
  2684. containsData = true;
  2685. containsData =
  2686. (this._queue.find(function (entry) { return entry.element === element; }) ? true : false) || containsData;
  2687. return containsData;
  2688. };
  2689. return AnimationTransitionNamespace;
  2690. }());
  2691. var TransitionAnimationEngine = /** @class */ (function () {
  2692. function TransitionAnimationEngine(bodyNode, driver, _normalizer) {
  2693. this.bodyNode = bodyNode;
  2694. this.driver = driver;
  2695. this._normalizer = _normalizer;
  2696. this.players = [];
  2697. this.newHostElements = new Map();
  2698. this.playersByElement = new Map();
  2699. this.playersByQueriedElement = new Map();
  2700. this.statesByElement = new Map();
  2701. this.disabledNodes = new Set();
  2702. this.totalAnimations = 0;
  2703. this.totalQueuedPlayers = 0;
  2704. this._namespaceLookup = {};
  2705. this._namespaceList = [];
  2706. this._flushFns = [];
  2707. this._whenQuietFns = [];
  2708. this.namespacesByHostElement = new Map();
  2709. this.collectedEnterElements = [];
  2710. this.collectedLeaveElements = [];
  2711. // this method is designed to be overridden by the code that uses this engine
  2712. this.onRemovalComplete = function (element, context) { };
  2713. }
  2714. /** @internal */
  2715. TransitionAnimationEngine.prototype._onRemovalComplete = function (element, context) { this.onRemovalComplete(element, context); };
  2716. Object.defineProperty(TransitionAnimationEngine.prototype, "queuedPlayers", {
  2717. get: function () {
  2718. var players = [];
  2719. this._namespaceList.forEach(function (ns) {
  2720. ns.players.forEach(function (player) {
  2721. if (player.queued) {
  2722. players.push(player);
  2723. }
  2724. });
  2725. });
  2726. return players;
  2727. },
  2728. enumerable: true,
  2729. configurable: true
  2730. });
  2731. TransitionAnimationEngine.prototype.createNamespace = function (namespaceId, hostElement) {
  2732. var ns = new AnimationTransitionNamespace(namespaceId, hostElement, this);
  2733. if (hostElement.parentNode) {
  2734. this._balanceNamespaceList(ns, hostElement);
  2735. }
  2736. else {
  2737. // defer this later until flush during when the host element has
  2738. // been inserted so that we know exactly where to place it in
  2739. // the namespace list
  2740. this.newHostElements.set(hostElement, ns);
  2741. // given that this host element is apart of the animation code, it
  2742. // may or may not be inserted by a parent node that is an of an
  2743. // animation renderer type. If this happens then we can still have
  2744. // access to this item when we query for :enter nodes. If the parent
  2745. // is a renderer then the set data-structure will normalize the entry
  2746. this.collectEnterElement(hostElement);
  2747. }
  2748. return this._namespaceLookup[namespaceId] = ns;
  2749. };
  2750. TransitionAnimationEngine.prototype._balanceNamespaceList = function (ns, hostElement) {
  2751. var limit = this._namespaceList.length - 1;
  2752. if (limit >= 0) {
  2753. var found = false;
  2754. for (var i = limit; i >= 0; i--) {
  2755. var nextNamespace = this._namespaceList[i];
  2756. if (this.driver.containsElement(nextNamespace.hostElement, hostElement)) {
  2757. this._namespaceList.splice(i + 1, 0, ns);
  2758. found = true;
  2759. break;
  2760. }
  2761. }
  2762. if (!found) {
  2763. this._namespaceList.splice(0, 0, ns);
  2764. }
  2765. }
  2766. else {
  2767. this._namespaceList.push(ns);
  2768. }
  2769. this.namespacesByHostElement.set(hostElement, ns);
  2770. return ns;
  2771. };
  2772. TransitionAnimationEngine.prototype.register = function (namespaceId, hostElement) {
  2773. var ns = this._namespaceLookup[namespaceId];
  2774. if (!ns) {
  2775. ns = this.createNamespace(namespaceId, hostElement);
  2776. }
  2777. return ns;
  2778. };
  2779. TransitionAnimationEngine.prototype.registerTrigger = function (namespaceId, name, trigger) {
  2780. var ns = this._namespaceLookup[namespaceId];
  2781. if (ns && ns.register(name, trigger)) {
  2782. this.totalAnimations++;
  2783. }
  2784. };
  2785. TransitionAnimationEngine.prototype.destroy = function (namespaceId, context) {
  2786. var _this = this;
  2787. if (!namespaceId)
  2788. return;
  2789. var ns = this._fetchNamespace(namespaceId);
  2790. this.afterFlush(function () {
  2791. _this.namespacesByHostElement.delete(ns.hostElement);
  2792. delete _this._namespaceLookup[namespaceId];
  2793. var index = _this._namespaceList.indexOf(ns);
  2794. if (index >= 0) {
  2795. _this._namespaceList.splice(index, 1);
  2796. }
  2797. });
  2798. this.afterFlushAnimationsDone(function () { return ns.destroy(context); });
  2799. };
  2800. TransitionAnimationEngine.prototype._fetchNamespace = function (id) { return this._namespaceLookup[id]; };
  2801. TransitionAnimationEngine.prototype.fetchNamespacesByElement = function (element) {
  2802. // normally there should only be one namespace per element, however
  2803. // if @triggers are placed on both the component element and then
  2804. // its host element (within the component code) then there will be
  2805. // two namespaces returned. We use a set here to simply the dedupe
  2806. // of namespaces incase there are multiple triggers both the elm and host
  2807. var namespaces = new Set();
  2808. var elementStates = this.statesByElement.get(element);
  2809. if (elementStates) {
  2810. var keys = Object.keys(elementStates);
  2811. for (var i = 0; i < keys.length; i++) {
  2812. var nsId = elementStates[keys[i]].namespaceId;
  2813. if (nsId) {
  2814. var ns = this._fetchNamespace(nsId);
  2815. if (ns) {
  2816. namespaces.add(ns);
  2817. }
  2818. }
  2819. }
  2820. }
  2821. return namespaces;
  2822. };
  2823. TransitionAnimationEngine.prototype.trigger = function (namespaceId, element, name, value) {
  2824. if (isElementNode(element)) {
  2825. var ns = this._fetchNamespace(namespaceId);
  2826. if (ns) {
  2827. ns.trigger(element, name, value);
  2828. return true;
  2829. }
  2830. }
  2831. return false;
  2832. };
  2833. TransitionAnimationEngine.prototype.insertNode = function (namespaceId, element, parent, insertBefore) {
  2834. if (!isElementNode(element))
  2835. return;
  2836. // special case for when an element is removed and reinserted (move operation)
  2837. // when this occurs we do not want to use the element for deletion later
  2838. var details = element[REMOVAL_FLAG];
  2839. if (details && details.setForRemoval) {
  2840. details.setForRemoval = false;
  2841. details.setForMove = true;
  2842. var index = this.collectedLeaveElements.indexOf(element);
  2843. if (index >= 0) {
  2844. this.collectedLeaveElements.splice(index, 1);
  2845. }
  2846. }
  2847. // in the event that the namespaceId is blank then the caller
  2848. // code does not contain any animation code in it, but it is
  2849. // just being called so that the node is marked as being inserted
  2850. if (namespaceId) {
  2851. var ns = this._fetchNamespace(namespaceId);
  2852. // This if-statement is a workaround for router issue #21947.
  2853. // The router sometimes hits a race condition where while a route
  2854. // is being instantiated a new navigation arrives, triggering leave
  2855. // animation of DOM that has not been fully initialized, until this
  2856. // is resolved, we need to handle the scenario when DOM is not in a
  2857. // consistent state during the animation.
  2858. if (ns) {
  2859. ns.insertNode(element, parent);
  2860. }
  2861. }
  2862. // only *directives and host elements are inserted before
  2863. if (insertBefore) {
  2864. this.collectEnterElement(element);
  2865. }
  2866. };
  2867. TransitionAnimationEngine.prototype.collectEnterElement = function (element) { this.collectedEnterElements.push(element); };
  2868. TransitionAnimationEngine.prototype.markElementAsDisabled = function (element, value) {
  2869. if (value) {
  2870. if (!this.disabledNodes.has(element)) {
  2871. this.disabledNodes.add(element);
  2872. addClass(element, DISABLED_CLASSNAME);
  2873. }
  2874. }
  2875. else if (this.disabledNodes.has(element)) {
  2876. this.disabledNodes.delete(element);
  2877. removeClass(element, DISABLED_CLASSNAME);
  2878. }
  2879. };
  2880. TransitionAnimationEngine.prototype.removeNode = function (namespaceId, element, isHostElement, context) {
  2881. if (isElementNode(element)) {
  2882. var ns = namespaceId ? this._fetchNamespace(namespaceId) : null;
  2883. if (ns) {
  2884. ns.removeNode(element, context);
  2885. }
  2886. else {
  2887. this.markElementAsRemoved(namespaceId, element, false, context);
  2888. }
  2889. if (isHostElement) {
  2890. var hostNS = this.namespacesByHostElement.get(element);
  2891. if (hostNS && hostNS.id !== namespaceId) {
  2892. hostNS.removeNode(element, context);
  2893. }
  2894. }
  2895. }
  2896. else {
  2897. this._onRemovalComplete(element, context);
  2898. }
  2899. };
  2900. TransitionAnimationEngine.prototype.markElementAsRemoved = function (namespaceId, element, hasAnimation, context) {
  2901. this.collectedLeaveElements.push(element);
  2902. element[REMOVAL_FLAG] = {
  2903. namespaceId: namespaceId,
  2904. setForRemoval: context, hasAnimation: hasAnimation,
  2905. removedBeforeQueried: false
  2906. };
  2907. };
  2908. TransitionAnimationEngine.prototype.listen = function (namespaceId, element, name, phase, callback) {
  2909. if (isElementNode(element)) {
  2910. return this._fetchNamespace(namespaceId).listen(element, name, phase, callback);
  2911. }
  2912. return function () { };
  2913. };
  2914. TransitionAnimationEngine.prototype._buildInstruction = function (entry, subTimelines, enterClassName, leaveClassName, skipBuildAst) {
  2915. return entry.transition.build(this.driver, entry.element, entry.fromState.value, entry.toState.value, enterClassName, leaveClassName, entry.fromState.options, entry.toState.options, subTimelines, skipBuildAst);
  2916. };
  2917. TransitionAnimationEngine.prototype.destroyInnerAnimations = function (containerElement) {
  2918. var _this = this;
  2919. var elements = this.driver.query(containerElement, NG_TRIGGER_SELECTOR, true);
  2920. elements.forEach(function (element) { return _this.destroyActiveAnimationsForElement(element); });
  2921. if (this.playersByQueriedElement.size == 0)
  2922. return;
  2923. elements = this.driver.query(containerElement, NG_ANIMATING_SELECTOR, true);
  2924. elements.forEach(function (element) { return _this.finishActiveQueriedAnimationOnElement(element); });
  2925. };
  2926. TransitionAnimationEngine.prototype.destroyActiveAnimationsForElement = function (element) {
  2927. var players = this.playersByElement.get(element);
  2928. if (players) {
  2929. players.forEach(function (player) {
  2930. // special case for when an element is set for destruction, but hasn't started.
  2931. // in this situation we want to delay the destruction until the flush occurs
  2932. // so that any event listeners attached to the player are triggered.
  2933. if (player.queued) {
  2934. player.markedForDestroy = true;
  2935. }
  2936. else {
  2937. player.destroy();
  2938. }
  2939. });
  2940. }
  2941. };
  2942. TransitionAnimationEngine.prototype.finishActiveQueriedAnimationOnElement = function (element) {
  2943. var players = this.playersByQueriedElement.get(element);
  2944. if (players) {
  2945. players.forEach(function (player) { return player.finish(); });
  2946. }
  2947. };
  2948. TransitionAnimationEngine.prototype.whenRenderingDone = function () {
  2949. var _this = this;
  2950. return new Promise(function (resolve) {
  2951. if (_this.players.length) {
  2952. return optimizeGroupPlayer(_this.players).onDone(function () { return resolve(); });
  2953. }
  2954. else {
  2955. resolve();
  2956. }
  2957. });
  2958. };
  2959. TransitionAnimationEngine.prototype.processLeaveNode = function (element) {
  2960. var _this = this;
  2961. var details = element[REMOVAL_FLAG];
  2962. if (details && details.setForRemoval) {
  2963. // this will prevent it from removing it twice
  2964. element[REMOVAL_FLAG] = NULL_REMOVAL_STATE;
  2965. if (details.namespaceId) {
  2966. this.destroyInnerAnimations(element);
  2967. var ns = this._fetchNamespace(details.namespaceId);
  2968. if (ns) {
  2969. ns.clearElementCache(element);
  2970. }
  2971. }
  2972. this._onRemovalComplete(element, details.setForRemoval);
  2973. }
  2974. if (this.driver.matchesElement(element, DISABLED_SELECTOR)) {
  2975. this.markElementAsDisabled(element, false);
  2976. }
  2977. this.driver.query(element, DISABLED_SELECTOR, true).forEach(function (node) {
  2978. _this.markElementAsDisabled(node, false);
  2979. });
  2980. };
  2981. TransitionAnimationEngine.prototype.flush = function (microtaskId) {
  2982. var _this = this;
  2983. if (microtaskId === void 0) { microtaskId = -1; }
  2984. var players = [];
  2985. if (this.newHostElements.size) {
  2986. this.newHostElements.forEach(function (ns, element) { return _this._balanceNamespaceList(ns, element); });
  2987. this.newHostElements.clear();
  2988. }
  2989. if (this.totalAnimations && this.collectedEnterElements.length) {
  2990. for (var i = 0; i < this.collectedEnterElements.length; i++) {
  2991. var elm = this.collectedEnterElements[i];
  2992. addClass(elm, STAR_CLASSNAME);
  2993. }
  2994. }
  2995. if (this._namespaceList.length &&
  2996. (this.totalQueuedPlayers || this.collectedLeaveElements.length)) {
  2997. var cleanupFns = [];
  2998. try {
  2999. players = this._flushAnimations(cleanupFns, microtaskId);
  3000. }
  3001. finally {
  3002. for (var i = 0; i < cleanupFns.length; i++) {
  3003. cleanupFns[i]();
  3004. }
  3005. }
  3006. }
  3007. else {
  3008. for (var i = 0; i < this.collectedLeaveElements.length; i++) {
  3009. var element = this.collectedLeaveElements[i];
  3010. this.processLeaveNode(element);
  3011. }
  3012. }
  3013. this.totalQueuedPlayers = 0;
  3014. this.collectedEnterElements.length = 0;
  3015. this.collectedLeaveElements.length = 0;
  3016. this._flushFns.forEach(function (fn) { return fn(); });
  3017. this._flushFns = [];
  3018. if (this._whenQuietFns.length) {
  3019. // we move these over to a variable so that
  3020. // if any new callbacks are registered in another
  3021. // flush they do not populate the existing set
  3022. var quietFns_1 = this._whenQuietFns;
  3023. this._whenQuietFns = [];
  3024. if (players.length) {
  3025. optimizeGroupPlayer(players).onDone(function () { quietFns_1.forEach(function (fn) { return fn(); }); });
  3026. }
  3027. else {
  3028. quietFns_1.forEach(function (fn) { return fn(); });
  3029. }
  3030. }
  3031. };
  3032. TransitionAnimationEngine.prototype.reportError = function (errors) {
  3033. throw new Error("Unable to process animations due to the following failed trigger transitions\n " + errors.join('\n'));
  3034. };
  3035. TransitionAnimationEngine.prototype._flushAnimations = function (cleanupFns, microtaskId) {
  3036. var _this = this;
  3037. var subTimelines = new ElementInstructionMap();
  3038. var skippedPlayers = [];
  3039. var skippedPlayersMap = new Map();
  3040. var queuedInstructions = [];
  3041. var queriedElements = new Map();
  3042. var allPreStyleElements = new Map();
  3043. var allPostStyleElements = new Map();
  3044. var disabledElementsSet = new Set();
  3045. this.disabledNodes.forEach(function (node) {
  3046. disabledElementsSet.add(node);
  3047. var nodesThatAreDisabled = _this.driver.query(node, QUEUED_SELECTOR, true);
  3048. for (var i_1 = 0; i_1 < nodesThatAreDisabled.length; i_1++) {
  3049. disabledElementsSet.add(nodesThatAreDisabled[i_1]);
  3050. }
  3051. });
  3052. var bodyNode = this.bodyNode;
  3053. var allTriggerElements = Array.from(this.statesByElement.keys());
  3054. var enterNodeMap = buildRootMap(allTriggerElements, this.collectedEnterElements);
  3055. // this must occur before the instructions are built below such that
  3056. // the :enter queries match the elements (since the timeline queries
  3057. // are fired during instruction building).
  3058. var enterNodeMapIds = new Map();
  3059. var i = 0;
  3060. enterNodeMap.forEach(function (nodes, root) {
  3061. var className = ENTER_CLASSNAME + i++;
  3062. enterNodeMapIds.set(root, className);
  3063. nodes.forEach(function (node) { return addClass(node, className); });
  3064. });
  3065. var allLeaveNodes = [];
  3066. var mergedLeaveNodes = new Set();
  3067. var leaveNodesWithoutAnimations = new Set();
  3068. for (var i_2 = 0; i_2 < this.collectedLeaveElements.length; i_2++) {
  3069. var element = this.collectedLeaveElements[i_2];
  3070. var details = element[REMOVAL_FLAG];
  3071. if (details && details.setForRemoval) {
  3072. allLeaveNodes.push(element);
  3073. mergedLeaveNodes.add(element);
  3074. if (details.hasAnimation) {
  3075. this.driver.query(element, STAR_SELECTOR, true).forEach(function (elm) { return mergedLeaveNodes.add(elm); });
  3076. }
  3077. else {
  3078. leaveNodesWithoutAnimations.add(element);
  3079. }
  3080. }
  3081. }
  3082. var leaveNodeMapIds = new Map();
  3083. var leaveNodeMap = buildRootMap(allTriggerElements, Array.from(mergedLeaveNodes));
  3084. leaveNodeMap.forEach(function (nodes, root) {
  3085. var className = LEAVE_CLASSNAME + i++;
  3086. leaveNodeMapIds.set(root, className);
  3087. nodes.forEach(function (node) { return addClass(node, className); });
  3088. });
  3089. cleanupFns.push(function () {
  3090. enterNodeMap.forEach(function (nodes, root) {
  3091. var className = enterNodeMapIds.get(root);
  3092. nodes.forEach(function (node) { return removeClass(node, className); });
  3093. });
  3094. leaveNodeMap.forEach(function (nodes, root) {
  3095. var className = leaveNodeMapIds.get(root);
  3096. nodes.forEach(function (node) { return removeClass(node, className); });
  3097. });
  3098. allLeaveNodes.forEach(function (element) { _this.processLeaveNode(element); });
  3099. });
  3100. var allPlayers = [];
  3101. var erroneousTransitions = [];
  3102. for (var i_3 = this._namespaceList.length - 1; i_3 >= 0; i_3--) {
  3103. var ns = this._namespaceList[i_3];
  3104. ns.drainQueuedTransitions(microtaskId).forEach(function (entry) {
  3105. var player = entry.player;
  3106. var element = entry.element;
  3107. allPlayers.push(player);
  3108. if (_this.collectedEnterElements.length) {
  3109. var details = element[REMOVAL_FLAG];
  3110. // move animations are currently not supported...
  3111. if (details && details.setForMove) {
  3112. player.destroy();
  3113. return;
  3114. }
  3115. }
  3116. var nodeIsOrphaned = !bodyNode || !_this.driver.containsElement(bodyNode, element);
  3117. var leaveClassName = leaveNodeMapIds.get(element);
  3118. var enterClassName = enterNodeMapIds.get(element);
  3119. var instruction = _this._buildInstruction(entry, subTimelines, enterClassName, leaveClassName, nodeIsOrphaned);
  3120. if (instruction.errors && instruction.errors.length) {
  3121. erroneousTransitions.push(instruction);
  3122. return;
  3123. }
  3124. // even though the element may not be apart of the DOM, it may
  3125. // still be added at a later point (due to the mechanics of content
  3126. // projection and/or dynamic component insertion) therefore it's
  3127. // important we still style the element.
  3128. if (nodeIsOrphaned) {
  3129. player.onStart(function () { return eraseStyles(element, instruction.fromStyles); });
  3130. player.onDestroy(function () { return setStyles(element, instruction.toStyles); });
  3131. skippedPlayers.push(player);
  3132. return;
  3133. }
  3134. // if a unmatched transition is queued to go then it SHOULD NOT render
  3135. // an animation and cancel the previously running animations.
  3136. if (entry.isFallbackTransition) {
  3137. player.onStart(function () { return eraseStyles(element, instruction.fromStyles); });
  3138. player.onDestroy(function () { return setStyles(element, instruction.toStyles); });
  3139. skippedPlayers.push(player);
  3140. return;
  3141. }
  3142. // this means that if a parent animation uses this animation as a sub trigger
  3143. // then it will instruct the timeline builder to not add a player delay, but
  3144. // instead stretch the first keyframe gap up until the animation starts. The
  3145. // reason this is important is to prevent extra initialization styles from being
  3146. // required by the user in the animation.
  3147. instruction.timelines.forEach(function (tl) { return tl.stretchStartingKeyframe = true; });
  3148. subTimelines.append(element, instruction.timelines);
  3149. var tuple = { instruction: instruction, player: player, element: element };
  3150. queuedInstructions.push(tuple);
  3151. instruction.queriedElements.forEach(function (element) { return getOrSetAsInMap(queriedElements, element, []).push(player); });
  3152. instruction.preStyleProps.forEach(function (stringMap, element) {
  3153. var props = Object.keys(stringMap);
  3154. if (props.length) {
  3155. var setVal_1 = allPreStyleElements.get(element);
  3156. if (!setVal_1) {
  3157. allPreStyleElements.set(element, setVal_1 = new Set());
  3158. }
  3159. props.forEach(function (prop) { return setVal_1.add(prop); });
  3160. }
  3161. });
  3162. instruction.postStyleProps.forEach(function (stringMap, element) {
  3163. var props = Object.keys(stringMap);
  3164. var setVal = allPostStyleElements.get(element);
  3165. if (!setVal) {
  3166. allPostStyleElements.set(element, setVal = new Set());
  3167. }
  3168. props.forEach(function (prop) { return setVal.add(prop); });
  3169. });
  3170. });
  3171. }
  3172. if (erroneousTransitions.length) {
  3173. var errors_1 = [];
  3174. erroneousTransitions.forEach(function (instruction) {
  3175. errors_1.push("@" + instruction.triggerName + " has failed due to:\n");
  3176. instruction.errors.forEach(function (error) { return errors_1.push("- " + error + "\n"); });
  3177. });
  3178. allPlayers.forEach(function (player) { return player.destroy(); });
  3179. this.reportError(errors_1);
  3180. }
  3181. var allPreviousPlayersMap = new Map();
  3182. // this map works to tell which element in the DOM tree is contained by
  3183. // which animation. Further down below this map will get populated once
  3184. // the players are built and in doing so it can efficiently figure out
  3185. // if a sub player is skipped due to a parent player having priority.
  3186. var animationElementMap = new Map();
  3187. queuedInstructions.forEach(function (entry) {
  3188. var element = entry.element;
  3189. if (subTimelines.has(element)) {
  3190. animationElementMap.set(element, element);
  3191. _this._beforeAnimationBuild(entry.player.namespaceId, entry.instruction, allPreviousPlayersMap);
  3192. }
  3193. });
  3194. skippedPlayers.forEach(function (player) {
  3195. var element = player.element;
  3196. var previousPlayers = _this._getPreviousPlayers(element, false, player.namespaceId, player.triggerName, null);
  3197. previousPlayers.forEach(function (prevPlayer) {
  3198. getOrSetAsInMap(allPreviousPlayersMap, element, []).push(prevPlayer);
  3199. prevPlayer.destroy();
  3200. });
  3201. });
  3202. // this is a special case for nodes that will be removed (either by)
  3203. // having their own leave animations or by being queried in a container
  3204. // that will be removed once a parent animation is complete. The idea
  3205. // here is that * styles must be identical to ! styles because of
  3206. // backwards compatibility (* is also filled in by default in many places).
  3207. // Otherwise * styles will return an empty value or auto since the element
  3208. // that is being getComputedStyle'd will not be visible (since * = destination)
  3209. var replaceNodes = allLeaveNodes.filter(function (node) {
  3210. return replacePostStylesAsPre(node, allPreStyleElements, allPostStyleElements);
  3211. });
  3212. // POST STAGE: fill the * styles
  3213. var postStylesMap = new Map();
  3214. var allLeaveQueriedNodes = cloakAndComputeStyles(postStylesMap, this.driver, leaveNodesWithoutAnimations, allPostStyleElements, AUTO_STYLE);
  3215. allLeaveQueriedNodes.forEach(function (node) {
  3216. if (replacePostStylesAsPre(node, allPreStyleElements, allPostStyleElements)) {
  3217. replaceNodes.push(node);
  3218. }
  3219. });
  3220. // PRE STAGE: fill the ! styles
  3221. var preStylesMap = new Map();
  3222. enterNodeMap.forEach(function (nodes, root) {
  3223. cloakAndComputeStyles(preStylesMap, _this.driver, new Set(nodes), allPreStyleElements, ɵPRE_STYLE);
  3224. });
  3225. replaceNodes.forEach(function (node) {
  3226. var post = postStylesMap.get(node);
  3227. var pre = preStylesMap.get(node);
  3228. postStylesMap.set(node, __assign({}, post, pre));
  3229. });
  3230. var rootPlayers = [];
  3231. var subPlayers = [];
  3232. var NO_PARENT_ANIMATION_ELEMENT_DETECTED = {};
  3233. queuedInstructions.forEach(function (entry) {
  3234. var element = entry.element, player = entry.player, instruction = entry.instruction;
  3235. // this means that it was never consumed by a parent animation which
  3236. // means that it is independent and therefore should be set for animation
  3237. if (subTimelines.has(element)) {
  3238. if (disabledElementsSet.has(element)) {
  3239. player.onDestroy(function () { return setStyles(element, instruction.toStyles); });
  3240. player.disabled = true;
  3241. player.overrideTotalTime(instruction.totalTime);
  3242. skippedPlayers.push(player);
  3243. return;
  3244. }
  3245. // this will flow up the DOM and query the map to figure out
  3246. // if a parent animation has priority over it. In the situation
  3247. // that a parent is detected then it will cancel the loop. If
  3248. // nothing is detected, or it takes a few hops to find a parent,
  3249. // then it will fill in the missing nodes and signal them as having
  3250. // a detected parent (or a NO_PARENT value via a special constant).
  3251. var parentWithAnimation_1 = NO_PARENT_ANIMATION_ELEMENT_DETECTED;
  3252. if (animationElementMap.size > 1) {
  3253. var elm = element;
  3254. var parentsToAdd = [];
  3255. while (elm = elm.parentNode) {
  3256. var detectedParent = animationElementMap.get(elm);
  3257. if (detectedParent) {
  3258. parentWithAnimation_1 = detectedParent;
  3259. break;
  3260. }
  3261. parentsToAdd.push(elm);
  3262. }
  3263. parentsToAdd.forEach(function (parent) { return animationElementMap.set(parent, parentWithAnimation_1); });
  3264. }
  3265. var innerPlayer = _this._buildAnimation(player.namespaceId, instruction, allPreviousPlayersMap, skippedPlayersMap, preStylesMap, postStylesMap);
  3266. player.setRealPlayer(innerPlayer);
  3267. if (parentWithAnimation_1 === NO_PARENT_ANIMATION_ELEMENT_DETECTED) {
  3268. rootPlayers.push(player);
  3269. }
  3270. else {
  3271. var parentPlayers = _this.playersByElement.get(parentWithAnimation_1);
  3272. if (parentPlayers && parentPlayers.length) {
  3273. player.parentPlayer = optimizeGroupPlayer(parentPlayers);
  3274. }
  3275. skippedPlayers.push(player);
  3276. }
  3277. }
  3278. else {
  3279. eraseStyles(element, instruction.fromStyles);
  3280. player.onDestroy(function () { return setStyles(element, instruction.toStyles); });
  3281. // there still might be a ancestor player animating this
  3282. // element therefore we will still add it as a sub player
  3283. // even if its animation may be disabled
  3284. subPlayers.push(player);
  3285. if (disabledElementsSet.has(element)) {
  3286. skippedPlayers.push(player);
  3287. }
  3288. }
  3289. });
  3290. // find all of the sub players' corresponding inner animation player
  3291. subPlayers.forEach(function (player) {
  3292. // even if any players are not found for a sub animation then it
  3293. // will still complete itself after the next tick since it's Noop
  3294. var playersForElement = skippedPlayersMap.get(player.element);
  3295. if (playersForElement && playersForElement.length) {
  3296. var innerPlayer = optimizeGroupPlayer(playersForElement);
  3297. player.setRealPlayer(innerPlayer);
  3298. }
  3299. });
  3300. // the reason why we don't actually play the animation is
  3301. // because all that a skipped player is designed to do is to
  3302. // fire the start/done transition callback events
  3303. skippedPlayers.forEach(function (player) {
  3304. if (player.parentPlayer) {
  3305. player.syncPlayerEvents(player.parentPlayer);
  3306. }
  3307. else {
  3308. player.destroy();
  3309. }
  3310. });
  3311. // run through all of the queued removals and see if they
  3312. // were picked up by a query. If not then perform the removal
  3313. // operation right away unless a parent animation is ongoing.
  3314. for (var i_4 = 0; i_4 < allLeaveNodes.length; i_4++) {
  3315. var element = allLeaveNodes[i_4];
  3316. var details = element[REMOVAL_FLAG];
  3317. removeClass(element, LEAVE_CLASSNAME);
  3318. // this means the element has a removal animation that is being
  3319. // taken care of and therefore the inner elements will hang around
  3320. // until that animation is over (or the parent queried animation)
  3321. if (details && details.hasAnimation)
  3322. continue;
  3323. var players = [];
  3324. // if this element is queried or if it contains queried children
  3325. // then we want for the element not to be removed from the page
  3326. // until the queried animations have finished
  3327. if (queriedElements.size) {
  3328. var queriedPlayerResults = queriedElements.get(element);
  3329. if (queriedPlayerResults && queriedPlayerResults.length) {
  3330. players.push.apply(players, __spread(queriedPlayerResults));
  3331. }
  3332. var queriedInnerElements = this.driver.query(element, NG_ANIMATING_SELECTOR, true);
  3333. for (var j = 0; j < queriedInnerElements.length; j++) {
  3334. var queriedPlayers = queriedElements.get(queriedInnerElements[j]);
  3335. if (queriedPlayers && queriedPlayers.length) {
  3336. players.push.apply(players, __spread(queriedPlayers));
  3337. }
  3338. }
  3339. }
  3340. var activePlayers = players.filter(function (p) { return !p.destroyed; });
  3341. if (activePlayers.length) {
  3342. removeNodesAfterAnimationDone(this, element, activePlayers);
  3343. }
  3344. else {
  3345. this.processLeaveNode(element);
  3346. }
  3347. }
  3348. // this is required so the cleanup method doesn't remove them
  3349. allLeaveNodes.length = 0;
  3350. rootPlayers.forEach(function (player) {
  3351. _this.players.push(player);
  3352. player.onDone(function () {
  3353. player.destroy();
  3354. var index = _this.players.indexOf(player);
  3355. _this.players.splice(index, 1);
  3356. });
  3357. player.play();
  3358. });
  3359. return rootPlayers;
  3360. };
  3361. TransitionAnimationEngine.prototype.elementContainsData = function (namespaceId, element) {
  3362. var containsData = false;
  3363. var details = element[REMOVAL_FLAG];
  3364. if (details && details.setForRemoval)
  3365. containsData = true;
  3366. if (this.playersByElement.has(element))
  3367. containsData = true;
  3368. if (this.playersByQueriedElement.has(element))
  3369. containsData = true;
  3370. if (this.statesByElement.has(element))
  3371. containsData = true;
  3372. return this._fetchNamespace(namespaceId).elementContainsData(element) || containsData;
  3373. };
  3374. TransitionAnimationEngine.prototype.afterFlush = function (callback) { this._flushFns.push(callback); };
  3375. TransitionAnimationEngine.prototype.afterFlushAnimationsDone = function (callback) { this._whenQuietFns.push(callback); };
  3376. TransitionAnimationEngine.prototype._getPreviousPlayers = function (element, isQueriedElement, namespaceId, triggerName, toStateValue) {
  3377. var players = [];
  3378. if (isQueriedElement) {
  3379. var queriedElementPlayers = this.playersByQueriedElement.get(element);
  3380. if (queriedElementPlayers) {
  3381. players = queriedElementPlayers;
  3382. }
  3383. }
  3384. else {
  3385. var elementPlayers = this.playersByElement.get(element);
  3386. if (elementPlayers) {
  3387. var isRemovalAnimation_1 = !toStateValue || toStateValue == VOID_VALUE;
  3388. elementPlayers.forEach(function (player) {
  3389. if (player.queued)
  3390. return;
  3391. if (!isRemovalAnimation_1 && player.triggerName != triggerName)
  3392. return;
  3393. players.push(player);
  3394. });
  3395. }
  3396. }
  3397. if (namespaceId || triggerName) {
  3398. players = players.filter(function (player) {
  3399. if (namespaceId && namespaceId != player.namespaceId)
  3400. return false;
  3401. if (triggerName && triggerName != player.triggerName)
  3402. return false;
  3403. return true;
  3404. });
  3405. }
  3406. return players;
  3407. };
  3408. TransitionAnimationEngine.prototype._beforeAnimationBuild = function (namespaceId, instruction, allPreviousPlayersMap) {
  3409. var e_1, _a;
  3410. var triggerName = instruction.triggerName;
  3411. var rootElement = instruction.element;
  3412. // when a removal animation occurs, ALL previous players are collected
  3413. // and destroyed (even if they are outside of the current namespace)
  3414. var targetNameSpaceId = instruction.isRemovalTransition ? undefined : namespaceId;
  3415. var targetTriggerName = instruction.isRemovalTransition ? undefined : triggerName;
  3416. var _loop_1 = function (timelineInstruction) {
  3417. var element = timelineInstruction.element;
  3418. var isQueriedElement = element !== rootElement;
  3419. var players = getOrSetAsInMap(allPreviousPlayersMap, element, []);
  3420. var previousPlayers = this_1._getPreviousPlayers(element, isQueriedElement, targetNameSpaceId, targetTriggerName, instruction.toState);
  3421. previousPlayers.forEach(function (player) {
  3422. var realPlayer = player.getRealPlayer();
  3423. if (realPlayer.beforeDestroy) {
  3424. realPlayer.beforeDestroy();
  3425. }
  3426. player.destroy();
  3427. players.push(player);
  3428. });
  3429. };
  3430. var this_1 = this;
  3431. try {
  3432. for (var _b = __values(instruction.timelines), _c = _b.next(); !_c.done; _c = _b.next()) {
  3433. var timelineInstruction = _c.value;
  3434. _loop_1(timelineInstruction);
  3435. }
  3436. }
  3437. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  3438. finally {
  3439. try {
  3440. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  3441. }
  3442. finally { if (e_1) throw e_1.error; }
  3443. }
  3444. // this needs to be done so that the PRE/POST styles can be
  3445. // computed properly without interfering with the previous animation
  3446. eraseStyles(rootElement, instruction.fromStyles);
  3447. };
  3448. TransitionAnimationEngine.prototype._buildAnimation = function (namespaceId, instruction, allPreviousPlayersMap, skippedPlayersMap, preStylesMap, postStylesMap) {
  3449. var _this = this;
  3450. var triggerName = instruction.triggerName;
  3451. var rootElement = instruction.element;
  3452. // we first run this so that the previous animation player
  3453. // data can be passed into the successive animation players
  3454. var allQueriedPlayers = [];
  3455. var allConsumedElements = new Set();
  3456. var allSubElements = new Set();
  3457. var allNewPlayers = instruction.timelines.map(function (timelineInstruction) {
  3458. var element = timelineInstruction.element;
  3459. allConsumedElements.add(element);
  3460. // FIXME (matsko): make sure to-be-removed animations are removed properly
  3461. var details = element[REMOVAL_FLAG];
  3462. if (details && details.removedBeforeQueried)
  3463. return new NoopAnimationPlayer(timelineInstruction.duration, timelineInstruction.delay);
  3464. var isQueriedElement = element !== rootElement;
  3465. var previousPlayers = flattenGroupPlayers((allPreviousPlayersMap.get(element) || EMPTY_PLAYER_ARRAY)
  3466. .map(function (p) { return p.getRealPlayer(); }))
  3467. .filter(function (p) {
  3468. // the `element` is not apart of the AnimationPlayer definition, but
  3469. // Mock/WebAnimations
  3470. // use the element within their implementation. This will be added in Angular5 to
  3471. // AnimationPlayer
  3472. var pp = p;
  3473. return pp.element ? pp.element === element : false;
  3474. });
  3475. var preStyles = preStylesMap.get(element);
  3476. var postStyles = postStylesMap.get(element);
  3477. var keyframes = normalizeKeyframes(_this.driver, _this._normalizer, element, timelineInstruction.keyframes, preStyles, postStyles);
  3478. var player = _this._buildPlayer(timelineInstruction, keyframes, previousPlayers);
  3479. // this means that this particular player belongs to a sub trigger. It is
  3480. // important that we match this player up with the corresponding (@trigger.listener)
  3481. if (timelineInstruction.subTimeline && skippedPlayersMap) {
  3482. allSubElements.add(element);
  3483. }
  3484. if (isQueriedElement) {
  3485. var wrappedPlayer = new TransitionAnimationPlayer(namespaceId, triggerName, element);
  3486. wrappedPlayer.setRealPlayer(player);
  3487. allQueriedPlayers.push(wrappedPlayer);
  3488. }
  3489. return player;
  3490. });
  3491. allQueriedPlayers.forEach(function (player) {
  3492. getOrSetAsInMap(_this.playersByQueriedElement, player.element, []).push(player);
  3493. player.onDone(function () { return deleteOrUnsetInMap(_this.playersByQueriedElement, player.element, player); });
  3494. });
  3495. allConsumedElements.forEach(function (element) { return addClass(element, NG_ANIMATING_CLASSNAME); });
  3496. var player = optimizeGroupPlayer(allNewPlayers);
  3497. player.onDestroy(function () {
  3498. allConsumedElements.forEach(function (element) { return removeClass(element, NG_ANIMATING_CLASSNAME); });
  3499. setStyles(rootElement, instruction.toStyles);
  3500. });
  3501. // this basically makes all of the callbacks for sub element animations
  3502. // be dependent on the upper players for when they finish
  3503. allSubElements.forEach(function (element) { getOrSetAsInMap(skippedPlayersMap, element, []).push(player); });
  3504. return player;
  3505. };
  3506. TransitionAnimationEngine.prototype._buildPlayer = function (instruction, keyframes, previousPlayers) {
  3507. if (keyframes.length > 0) {
  3508. return this.driver.animate(instruction.element, keyframes, instruction.duration, instruction.delay, instruction.easing, previousPlayers);
  3509. }
  3510. // special case for when an empty transition|definition is provided
  3511. // ... there is no point in rendering an empty animation
  3512. return new NoopAnimationPlayer(instruction.duration, instruction.delay);
  3513. };
  3514. return TransitionAnimationEngine;
  3515. }());
  3516. var TransitionAnimationPlayer = /** @class */ (function () {
  3517. function TransitionAnimationPlayer(namespaceId, triggerName, element) {
  3518. this.namespaceId = namespaceId;
  3519. this.triggerName = triggerName;
  3520. this.element = element;
  3521. this._player = new NoopAnimationPlayer();
  3522. this._containsRealPlayer = false;
  3523. this._queuedCallbacks = {};
  3524. this.destroyed = false;
  3525. this.markedForDestroy = false;
  3526. this.disabled = false;
  3527. this.queued = true;
  3528. this.totalTime = 0;
  3529. }
  3530. TransitionAnimationPlayer.prototype.setRealPlayer = function (player) {
  3531. var _this = this;
  3532. if (this._containsRealPlayer)
  3533. return;
  3534. this._player = player;
  3535. Object.keys(this._queuedCallbacks).forEach(function (phase) {
  3536. _this._queuedCallbacks[phase].forEach(function (callback) { return listenOnPlayer(player, phase, undefined, callback); });
  3537. });
  3538. this._queuedCallbacks = {};
  3539. this._containsRealPlayer = true;
  3540. this.overrideTotalTime(player.totalTime);
  3541. this.queued = false;
  3542. };
  3543. TransitionAnimationPlayer.prototype.getRealPlayer = function () { return this._player; };
  3544. TransitionAnimationPlayer.prototype.overrideTotalTime = function (totalTime) { this.totalTime = totalTime; };
  3545. TransitionAnimationPlayer.prototype.syncPlayerEvents = function (player) {
  3546. var _this = this;
  3547. var p = this._player;
  3548. if (p.triggerCallback) {
  3549. player.onStart(function () { return p.triggerCallback('start'); });
  3550. }
  3551. player.onDone(function () { return _this.finish(); });
  3552. player.onDestroy(function () { return _this.destroy(); });
  3553. };
  3554. TransitionAnimationPlayer.prototype._queueEvent = function (name, callback) {
  3555. getOrSetAsInMap(this._queuedCallbacks, name, []).push(callback);
  3556. };
  3557. TransitionAnimationPlayer.prototype.onDone = function (fn) {
  3558. if (this.queued) {
  3559. this._queueEvent('done', fn);
  3560. }
  3561. this._player.onDone(fn);
  3562. };
  3563. TransitionAnimationPlayer.prototype.onStart = function (fn) {
  3564. if (this.queued) {
  3565. this._queueEvent('start', fn);
  3566. }
  3567. this._player.onStart(fn);
  3568. };
  3569. TransitionAnimationPlayer.prototype.onDestroy = function (fn) {
  3570. if (this.queued) {
  3571. this._queueEvent('destroy', fn);
  3572. }
  3573. this._player.onDestroy(fn);
  3574. };
  3575. TransitionAnimationPlayer.prototype.init = function () { this._player.init(); };
  3576. TransitionAnimationPlayer.prototype.hasStarted = function () { return this.queued ? false : this._player.hasStarted(); };
  3577. TransitionAnimationPlayer.prototype.play = function () { !this.queued && this._player.play(); };
  3578. TransitionAnimationPlayer.prototype.pause = function () { !this.queued && this._player.pause(); };
  3579. TransitionAnimationPlayer.prototype.restart = function () { !this.queued && this._player.restart(); };
  3580. TransitionAnimationPlayer.prototype.finish = function () { this._player.finish(); };
  3581. TransitionAnimationPlayer.prototype.destroy = function () {
  3582. this.destroyed = true;
  3583. this._player.destroy();
  3584. };
  3585. TransitionAnimationPlayer.prototype.reset = function () { !this.queued && this._player.reset(); };
  3586. TransitionAnimationPlayer.prototype.setPosition = function (p) {
  3587. if (!this.queued) {
  3588. this._player.setPosition(p);
  3589. }
  3590. };
  3591. TransitionAnimationPlayer.prototype.getPosition = function () { return this.queued ? 0 : this._player.getPosition(); };
  3592. /** @internal */
  3593. TransitionAnimationPlayer.prototype.triggerCallback = function (phaseName) {
  3594. var p = this._player;
  3595. if (p.triggerCallback) {
  3596. p.triggerCallback(phaseName);
  3597. }
  3598. };
  3599. return TransitionAnimationPlayer;
  3600. }());
  3601. function deleteOrUnsetInMap(map, key, value) {
  3602. var currentValues;
  3603. if (map instanceof Map) {
  3604. currentValues = map.get(key);
  3605. if (currentValues) {
  3606. if (currentValues.length) {
  3607. var index = currentValues.indexOf(value);
  3608. currentValues.splice(index, 1);
  3609. }
  3610. if (currentValues.length == 0) {
  3611. map.delete(key);
  3612. }
  3613. }
  3614. }
  3615. else {
  3616. currentValues = map[key];
  3617. if (currentValues) {
  3618. if (currentValues.length) {
  3619. var index = currentValues.indexOf(value);
  3620. currentValues.splice(index, 1);
  3621. }
  3622. if (currentValues.length == 0) {
  3623. delete map[key];
  3624. }
  3625. }
  3626. }
  3627. return currentValues;
  3628. }
  3629. function normalizeTriggerValue(value) {
  3630. // we use `!= null` here because it's the most simple
  3631. // way to test against a "falsy" value without mixing
  3632. // in empty strings or a zero value. DO NOT OPTIMIZE.
  3633. return value != null ? value : null;
  3634. }
  3635. function isElementNode(node) {
  3636. return node && node['nodeType'] === 1;
  3637. }
  3638. function isTriggerEventValid(eventName) {
  3639. return eventName == 'start' || eventName == 'done';
  3640. }
  3641. function cloakElement(element, value) {
  3642. var oldValue = element.style.display;
  3643. element.style.display = value != null ? value : 'none';
  3644. return oldValue;
  3645. }
  3646. function cloakAndComputeStyles(valuesMap, driver, elements, elementPropsMap, defaultStyle) {
  3647. var cloakVals = [];
  3648. elements.forEach(function (element) { return cloakVals.push(cloakElement(element)); });
  3649. var failedElements = [];
  3650. elementPropsMap.forEach(function (props, element) {
  3651. var styles = {};
  3652. props.forEach(function (prop) {
  3653. var value = styles[prop] = driver.computeStyle(element, prop, defaultStyle);
  3654. // there is no easy way to detect this because a sub element could be removed
  3655. // by a parent animation element being detached.
  3656. if (!value || value.length == 0) {
  3657. element[REMOVAL_FLAG] = NULL_REMOVED_QUERIED_STATE;
  3658. failedElements.push(element);
  3659. }
  3660. });
  3661. valuesMap.set(element, styles);
  3662. });
  3663. // we use a index variable here since Set.forEach(a, i) does not return
  3664. // an index value for the closure (but instead just the value)
  3665. var i = 0;
  3666. elements.forEach(function (element) { return cloakElement(element, cloakVals[i++]); });
  3667. return failedElements;
  3668. }
  3669. /*
  3670. Since the Angular renderer code will return a collection of inserted
  3671. nodes in all areas of a DOM tree, it's up to this algorithm to figure
  3672. out which nodes are roots for each animation @trigger.
  3673. By placing each inserted node into a Set and traversing upwards, it
  3674. is possible to find the @trigger elements and well any direct *star
  3675. insertion nodes, if a @trigger root is found then the enter element
  3676. is placed into the Map[@trigger] spot.
  3677. */
  3678. function buildRootMap(roots, nodes) {
  3679. var rootMap = new Map();
  3680. roots.forEach(function (root) { return rootMap.set(root, []); });
  3681. if (nodes.length == 0)
  3682. return rootMap;
  3683. var NULL_NODE = 1;
  3684. var nodeSet = new Set(nodes);
  3685. var localRootMap = new Map();
  3686. function getRoot(node) {
  3687. if (!node)
  3688. return NULL_NODE;
  3689. var root = localRootMap.get(node);
  3690. if (root)
  3691. return root;
  3692. var parent = node.parentNode;
  3693. if (rootMap.has(parent)) { // ngIf inside @trigger
  3694. root = parent;
  3695. }
  3696. else if (nodeSet.has(parent)) { // ngIf inside ngIf
  3697. root = NULL_NODE;
  3698. }
  3699. else { // recurse upwards
  3700. root = getRoot(parent);
  3701. }
  3702. localRootMap.set(node, root);
  3703. return root;
  3704. }
  3705. nodes.forEach(function (node) {
  3706. var root = getRoot(node);
  3707. if (root !== NULL_NODE) {
  3708. rootMap.get(root).push(node);
  3709. }
  3710. });
  3711. return rootMap;
  3712. }
  3713. var CLASSES_CACHE_KEY = '$$classes';
  3714. function addClass(element, className) {
  3715. if (element.classList) {
  3716. element.classList.add(className);
  3717. }
  3718. else {
  3719. var classes = element[CLASSES_CACHE_KEY];
  3720. if (!classes) {
  3721. classes = element[CLASSES_CACHE_KEY] = {};
  3722. }
  3723. classes[className] = true;
  3724. }
  3725. }
  3726. function removeClass(element, className) {
  3727. if (element.classList) {
  3728. element.classList.remove(className);
  3729. }
  3730. else {
  3731. var classes = element[CLASSES_CACHE_KEY];
  3732. if (classes) {
  3733. delete classes[className];
  3734. }
  3735. }
  3736. }
  3737. function removeNodesAfterAnimationDone(engine, element, players) {
  3738. optimizeGroupPlayer(players).onDone(function () { return engine.processLeaveNode(element); });
  3739. }
  3740. function flattenGroupPlayers(players) {
  3741. var finalPlayers = [];
  3742. _flattenGroupPlayersRecur(players, finalPlayers);
  3743. return finalPlayers;
  3744. }
  3745. function _flattenGroupPlayersRecur(players, finalPlayers) {
  3746. for (var i = 0; i < players.length; i++) {
  3747. var player = players[i];
  3748. if (player instanceof ɵAnimationGroupPlayer) {
  3749. _flattenGroupPlayersRecur(player.players, finalPlayers);
  3750. }
  3751. else {
  3752. finalPlayers.push(player);
  3753. }
  3754. }
  3755. }
  3756. function objEquals(a, b) {
  3757. var k1 = Object.keys(a);
  3758. var k2 = Object.keys(b);
  3759. if (k1.length != k2.length)
  3760. return false;
  3761. for (var i = 0; i < k1.length; i++) {
  3762. var prop = k1[i];
  3763. if (!b.hasOwnProperty(prop) || a[prop] !== b[prop])
  3764. return false;
  3765. }
  3766. return true;
  3767. }
  3768. function replacePostStylesAsPre(element, allPreStyleElements, allPostStyleElements) {
  3769. var postEntry = allPostStyleElements.get(element);
  3770. if (!postEntry)
  3771. return false;
  3772. var preEntry = allPreStyleElements.get(element);
  3773. if (preEntry) {
  3774. postEntry.forEach(function (data) { return preEntry.add(data); });
  3775. }
  3776. else {
  3777. allPreStyleElements.set(element, postEntry);
  3778. }
  3779. allPostStyleElements.delete(element);
  3780. return true;
  3781. }
  3782. var AnimationEngine = /** @class */ (function () {
  3783. function AnimationEngine(bodyNode, _driver, normalizer) {
  3784. var _this = this;
  3785. this.bodyNode = bodyNode;
  3786. this._driver = _driver;
  3787. this._triggerCache = {};
  3788. // this method is designed to be overridden by the code that uses this engine
  3789. this.onRemovalComplete = function (element, context) { };
  3790. this._transitionEngine = new TransitionAnimationEngine(bodyNode, _driver, normalizer);
  3791. this._timelineEngine = new TimelineAnimationEngine(bodyNode, _driver, normalizer);
  3792. this._transitionEngine.onRemovalComplete = function (element, context) {
  3793. return _this.onRemovalComplete(element, context);
  3794. };
  3795. }
  3796. AnimationEngine.prototype.registerTrigger = function (componentId, namespaceId, hostElement, name, metadata) {
  3797. var cacheKey = componentId + '-' + name;
  3798. var trigger = this._triggerCache[cacheKey];
  3799. if (!trigger) {
  3800. var errors = [];
  3801. var ast = buildAnimationAst(this._driver, metadata, errors);
  3802. if (errors.length) {
  3803. throw new Error("The animation trigger \"" + name + "\" has failed to build due to the following errors:\n - " + errors.join("\n - "));
  3804. }
  3805. trigger = buildTrigger(name, ast);
  3806. this._triggerCache[cacheKey] = trigger;
  3807. }
  3808. this._transitionEngine.registerTrigger(namespaceId, name, trigger);
  3809. };
  3810. AnimationEngine.prototype.register = function (namespaceId, hostElement) {
  3811. this._transitionEngine.register(namespaceId, hostElement);
  3812. };
  3813. AnimationEngine.prototype.destroy = function (namespaceId, context) {
  3814. this._transitionEngine.destroy(namespaceId, context);
  3815. };
  3816. AnimationEngine.prototype.onInsert = function (namespaceId, element, parent, insertBefore) {
  3817. this._transitionEngine.insertNode(namespaceId, element, parent, insertBefore);
  3818. };
  3819. AnimationEngine.prototype.onRemove = function (namespaceId, element, context, isHostElement) {
  3820. this._transitionEngine.removeNode(namespaceId, element, isHostElement || false, context);
  3821. };
  3822. AnimationEngine.prototype.disableAnimations = function (element, disable) {
  3823. this._transitionEngine.markElementAsDisabled(element, disable);
  3824. };
  3825. AnimationEngine.prototype.process = function (namespaceId, element, property, value) {
  3826. if (property.charAt(0) == '@') {
  3827. var _a = __read(parseTimelineCommand(property), 2), id = _a[0], action = _a[1];
  3828. var args = value;
  3829. this._timelineEngine.command(id, element, action, args);
  3830. }
  3831. else {
  3832. this._transitionEngine.trigger(namespaceId, element, property, value);
  3833. }
  3834. };
  3835. AnimationEngine.prototype.listen = function (namespaceId, element, eventName, eventPhase, callback) {
  3836. // @@listen
  3837. if (eventName.charAt(0) == '@') {
  3838. var _a = __read(parseTimelineCommand(eventName), 2), id = _a[0], action = _a[1];
  3839. return this._timelineEngine.listen(id, element, action, callback);
  3840. }
  3841. return this._transitionEngine.listen(namespaceId, element, eventName, eventPhase, callback);
  3842. };
  3843. AnimationEngine.prototype.flush = function (microtaskId) {
  3844. if (microtaskId === void 0) { microtaskId = -1; }
  3845. this._transitionEngine.flush(microtaskId);
  3846. };
  3847. Object.defineProperty(AnimationEngine.prototype, "players", {
  3848. get: function () {
  3849. return this._transitionEngine.players
  3850. .concat(this._timelineEngine.players);
  3851. },
  3852. enumerable: true,
  3853. configurable: true
  3854. });
  3855. AnimationEngine.prototype.whenRenderingDone = function () { return this._transitionEngine.whenRenderingDone(); };
  3856. return AnimationEngine;
  3857. }());
  3858. /**
  3859. * @license
  3860. * Copyright Google Inc. All Rights Reserved.
  3861. *
  3862. * Use of this source code is governed by an MIT-style license that can be
  3863. * found in the LICENSE file at https://angular.io/license
  3864. */
  3865. /**
  3866. * Returns an instance of `SpecialCasedStyles` if and when any special (non animateable) styles are
  3867. * detected.
  3868. *
  3869. * In CSS there exist properties that cannot be animated within a keyframe animation
  3870. * (whether it be via CSS keyframes or web-animations) and the animation implementation
  3871. * will ignore them. This function is designed to detect those special cased styles and
  3872. * return a container that will be executed at the start and end of the animation.
  3873. *
  3874. * @returns an instance of `SpecialCasedStyles` if any special styles are detected otherwise `null`
  3875. */
  3876. function packageNonAnimatableStyles(element, styles) {
  3877. var startStyles = null;
  3878. var endStyles = null;
  3879. if (Array.isArray(styles) && styles.length) {
  3880. startStyles = filterNonAnimatableStyles(styles[0]);
  3881. if (styles.length > 1) {
  3882. endStyles = filterNonAnimatableStyles(styles[styles.length - 1]);
  3883. }
  3884. }
  3885. else if (styles) {
  3886. startStyles = filterNonAnimatableStyles(styles);
  3887. }
  3888. return (startStyles || endStyles) ? new SpecialCasedStyles(element, startStyles, endStyles) :
  3889. null;
  3890. }
  3891. /**
  3892. * Designed to be executed during a keyframe-based animation to apply any special-cased styles.
  3893. *
  3894. * When started (when the `start()` method is run) then the provided `startStyles`
  3895. * will be applied. When finished (when the `finish()` method is called) the
  3896. * `endStyles` will be applied as well any any starting styles. Finally when
  3897. * `destroy()` is called then all styles will be removed.
  3898. */
  3899. var SpecialCasedStyles = /** @class */ (function () {
  3900. function SpecialCasedStyles(_element, _startStyles, _endStyles) {
  3901. this._element = _element;
  3902. this._startStyles = _startStyles;
  3903. this._endStyles = _endStyles;
  3904. this._state = 0 /* Pending */;
  3905. var initialStyles = SpecialCasedStyles.initialStylesByElement.get(_element);
  3906. if (!initialStyles) {
  3907. SpecialCasedStyles.initialStylesByElement.set(_element, initialStyles = {});
  3908. }
  3909. this._initialStyles = initialStyles;
  3910. }
  3911. SpecialCasedStyles.prototype.start = function () {
  3912. if (this._state < 1 /* Started */) {
  3913. if (this._startStyles) {
  3914. setStyles(this._element, this._startStyles, this._initialStyles);
  3915. }
  3916. this._state = 1 /* Started */;
  3917. }
  3918. };
  3919. SpecialCasedStyles.prototype.finish = function () {
  3920. this.start();
  3921. if (this._state < 2 /* Finished */) {
  3922. setStyles(this._element, this._initialStyles);
  3923. if (this._endStyles) {
  3924. setStyles(this._element, this._endStyles);
  3925. this._endStyles = null;
  3926. }
  3927. this._state = 1 /* Started */;
  3928. }
  3929. };
  3930. SpecialCasedStyles.prototype.destroy = function () {
  3931. this.finish();
  3932. if (this._state < 3 /* Destroyed */) {
  3933. SpecialCasedStyles.initialStylesByElement.delete(this._element);
  3934. if (this._startStyles) {
  3935. eraseStyles(this._element, this._startStyles);
  3936. this._endStyles = null;
  3937. }
  3938. if (this._endStyles) {
  3939. eraseStyles(this._element, this._endStyles);
  3940. this._endStyles = null;
  3941. }
  3942. setStyles(this._element, this._initialStyles);
  3943. this._state = 3 /* Destroyed */;
  3944. }
  3945. };
  3946. SpecialCasedStyles.initialStylesByElement = new WeakMap();
  3947. return SpecialCasedStyles;
  3948. }());
  3949. function filterNonAnimatableStyles(styles) {
  3950. var result = null;
  3951. var props = Object.keys(styles);
  3952. for (var i = 0; i < props.length; i++) {
  3953. var prop = props[i];
  3954. if (isNonAnimatableStyle(prop)) {
  3955. result = result || {};
  3956. result[prop] = styles[prop];
  3957. }
  3958. }
  3959. return result;
  3960. }
  3961. function isNonAnimatableStyle(prop) {
  3962. return prop === 'display' || prop === 'position';
  3963. }
  3964. /**
  3965. * @license
  3966. * Copyright Google Inc. All Rights Reserved.
  3967. *
  3968. * Use of this source code is governed by an MIT-style license that can be
  3969. * found in the LICENSE file at https://angular.io/license
  3970. */
  3971. var ELAPSED_TIME_MAX_DECIMAL_PLACES = 3;
  3972. var ANIMATION_PROP = 'animation';
  3973. var ANIMATIONEND_EVENT = 'animationend';
  3974. var ONE_SECOND$1 = 1000;
  3975. var ElementAnimationStyleHandler = /** @class */ (function () {
  3976. function ElementAnimationStyleHandler(_element, _name, _duration, _delay, _easing, _fillMode, _onDoneFn) {
  3977. var _this = this;
  3978. this._element = _element;
  3979. this._name = _name;
  3980. this._duration = _duration;
  3981. this._delay = _delay;
  3982. this._easing = _easing;
  3983. this._fillMode = _fillMode;
  3984. this._onDoneFn = _onDoneFn;
  3985. this._finished = false;
  3986. this._destroyed = false;
  3987. this._startTime = 0;
  3988. this._position = 0;
  3989. this._eventFn = function (e) { return _this._handleCallback(e); };
  3990. }
  3991. ElementAnimationStyleHandler.prototype.apply = function () {
  3992. applyKeyframeAnimation(this._element, this._duration + "ms " + this._easing + " " + this._delay + "ms 1 normal " + this._fillMode + " " + this._name);
  3993. addRemoveAnimationEvent(this._element, this._eventFn, false);
  3994. this._startTime = Date.now();
  3995. };
  3996. ElementAnimationStyleHandler.prototype.pause = function () { playPauseAnimation(this._element, this._name, 'paused'); };
  3997. ElementAnimationStyleHandler.prototype.resume = function () { playPauseAnimation(this._element, this._name, 'running'); };
  3998. ElementAnimationStyleHandler.prototype.setPosition = function (position) {
  3999. var index = findIndexForAnimation(this._element, this._name);
  4000. this._position = position * this._duration;
  4001. setAnimationStyle(this._element, 'Delay', "-" + this._position + "ms", index);
  4002. };
  4003. ElementAnimationStyleHandler.prototype.getPosition = function () { return this._position; };
  4004. ElementAnimationStyleHandler.prototype._handleCallback = function (event) {
  4005. var timestamp = event._ngTestManualTimestamp || Date.now();
  4006. var elapsedTime = parseFloat(event.elapsedTime.toFixed(ELAPSED_TIME_MAX_DECIMAL_PLACES)) * ONE_SECOND$1;
  4007. if (event.animationName == this._name &&
  4008. Math.max(timestamp - this._startTime, 0) >= this._delay && elapsedTime >= this._duration) {
  4009. this.finish();
  4010. }
  4011. };
  4012. ElementAnimationStyleHandler.prototype.finish = function () {
  4013. if (this._finished)
  4014. return;
  4015. this._finished = true;
  4016. this._onDoneFn();
  4017. addRemoveAnimationEvent(this._element, this._eventFn, true);
  4018. };
  4019. ElementAnimationStyleHandler.prototype.destroy = function () {
  4020. if (this._destroyed)
  4021. return;
  4022. this._destroyed = true;
  4023. this.finish();
  4024. removeKeyframeAnimation(this._element, this._name);
  4025. };
  4026. return ElementAnimationStyleHandler;
  4027. }());
  4028. function playPauseAnimation(element, name, status) {
  4029. var index = findIndexForAnimation(element, name);
  4030. setAnimationStyle(element, 'PlayState', status, index);
  4031. }
  4032. function applyKeyframeAnimation(element, value) {
  4033. var anim = getAnimationStyle(element, '').trim();
  4034. var index = 0;
  4035. if (anim.length) {
  4036. index = countChars(anim, ',') + 1;
  4037. value = anim + ", " + value;
  4038. }
  4039. setAnimationStyle(element, '', value);
  4040. return index;
  4041. }
  4042. function removeKeyframeAnimation(element, name) {
  4043. var anim = getAnimationStyle(element, '');
  4044. var tokens = anim.split(',');
  4045. var index = findMatchingTokenIndex(tokens, name);
  4046. if (index >= 0) {
  4047. tokens.splice(index, 1);
  4048. var newValue = tokens.join(',');
  4049. setAnimationStyle(element, '', newValue);
  4050. }
  4051. }
  4052. function findIndexForAnimation(element, value) {
  4053. var anim = getAnimationStyle(element, '');
  4054. if (anim.indexOf(',') > 0) {
  4055. var tokens = anim.split(',');
  4056. return findMatchingTokenIndex(tokens, value);
  4057. }
  4058. return findMatchingTokenIndex([anim], value);
  4059. }
  4060. function findMatchingTokenIndex(tokens, searchToken) {
  4061. for (var i = 0; i < tokens.length; i++) {
  4062. if (tokens[i].indexOf(searchToken) >= 0) {
  4063. return i;
  4064. }
  4065. }
  4066. return -1;
  4067. }
  4068. function addRemoveAnimationEvent(element, fn, doRemove) {
  4069. doRemove ? element.removeEventListener(ANIMATIONEND_EVENT, fn) :
  4070. element.addEventListener(ANIMATIONEND_EVENT, fn);
  4071. }
  4072. function setAnimationStyle(element, name, value, index) {
  4073. var prop = ANIMATION_PROP + name;
  4074. if (index != null) {
  4075. var oldValue = element.style[prop];
  4076. if (oldValue.length) {
  4077. var tokens = oldValue.split(',');
  4078. tokens[index] = value;
  4079. value = tokens.join(',');
  4080. }
  4081. }
  4082. element.style[prop] = value;
  4083. }
  4084. function getAnimationStyle(element, name) {
  4085. return element.style[ANIMATION_PROP + name];
  4086. }
  4087. function countChars(value, char) {
  4088. var count = 0;
  4089. for (var i = 0; i < value.length; i++) {
  4090. var c = value.charAt(i);
  4091. if (c === char)
  4092. count++;
  4093. }
  4094. return count;
  4095. }
  4096. var DEFAULT_FILL_MODE = 'forwards';
  4097. var DEFAULT_EASING = 'linear';
  4098. var CssKeyframesPlayer = /** @class */ (function () {
  4099. function CssKeyframesPlayer(element, keyframes, animationName, _duration, _delay, easing, _finalStyles, _specialStyles) {
  4100. this.element = element;
  4101. this.keyframes = keyframes;
  4102. this.animationName = animationName;
  4103. this._duration = _duration;
  4104. this._delay = _delay;
  4105. this._finalStyles = _finalStyles;
  4106. this._specialStyles = _specialStyles;
  4107. this._onDoneFns = [];
  4108. this._onStartFns = [];
  4109. this._onDestroyFns = [];
  4110. this._started = false;
  4111. this.currentSnapshot = {};
  4112. this._state = 0;
  4113. this.easing = easing || DEFAULT_EASING;
  4114. this.totalTime = _duration + _delay;
  4115. this._buildStyler();
  4116. }
  4117. CssKeyframesPlayer.prototype.onStart = function (fn) { this._onStartFns.push(fn); };
  4118. CssKeyframesPlayer.prototype.onDone = function (fn) { this._onDoneFns.push(fn); };
  4119. CssKeyframesPlayer.prototype.onDestroy = function (fn) { this._onDestroyFns.push(fn); };
  4120. CssKeyframesPlayer.prototype.destroy = function () {
  4121. this.init();
  4122. if (this._state >= 4 /* DESTROYED */)
  4123. return;
  4124. this._state = 4 /* DESTROYED */;
  4125. this._styler.destroy();
  4126. this._flushStartFns();
  4127. this._flushDoneFns();
  4128. if (this._specialStyles) {
  4129. this._specialStyles.destroy();
  4130. }
  4131. this._onDestroyFns.forEach(function (fn) { return fn(); });
  4132. this._onDestroyFns = [];
  4133. };
  4134. CssKeyframesPlayer.prototype._flushDoneFns = function () {
  4135. this._onDoneFns.forEach(function (fn) { return fn(); });
  4136. this._onDoneFns = [];
  4137. };
  4138. CssKeyframesPlayer.prototype._flushStartFns = function () {
  4139. this._onStartFns.forEach(function (fn) { return fn(); });
  4140. this._onStartFns = [];
  4141. };
  4142. CssKeyframesPlayer.prototype.finish = function () {
  4143. this.init();
  4144. if (this._state >= 3 /* FINISHED */)
  4145. return;
  4146. this._state = 3 /* FINISHED */;
  4147. this._styler.finish();
  4148. this._flushStartFns();
  4149. if (this._specialStyles) {
  4150. this._specialStyles.finish();
  4151. }
  4152. this._flushDoneFns();
  4153. };
  4154. CssKeyframesPlayer.prototype.setPosition = function (value) { this._styler.setPosition(value); };
  4155. CssKeyframesPlayer.prototype.getPosition = function () { return this._styler.getPosition(); };
  4156. CssKeyframesPlayer.prototype.hasStarted = function () { return this._state >= 2 /* STARTED */; };
  4157. CssKeyframesPlayer.prototype.init = function () {
  4158. if (this._state >= 1 /* INITIALIZED */)
  4159. return;
  4160. this._state = 1 /* INITIALIZED */;
  4161. var elm = this.element;
  4162. this._styler.apply();
  4163. if (this._delay) {
  4164. this._styler.pause();
  4165. }
  4166. };
  4167. CssKeyframesPlayer.prototype.play = function () {
  4168. this.init();
  4169. if (!this.hasStarted()) {
  4170. this._flushStartFns();
  4171. this._state = 2 /* STARTED */;
  4172. if (this._specialStyles) {
  4173. this._specialStyles.start();
  4174. }
  4175. }
  4176. this._styler.resume();
  4177. };
  4178. CssKeyframesPlayer.prototype.pause = function () {
  4179. this.init();
  4180. this._styler.pause();
  4181. };
  4182. CssKeyframesPlayer.prototype.restart = function () {
  4183. this.reset();
  4184. this.play();
  4185. };
  4186. CssKeyframesPlayer.prototype.reset = function () {
  4187. this._styler.destroy();
  4188. this._buildStyler();
  4189. this._styler.apply();
  4190. };
  4191. CssKeyframesPlayer.prototype._buildStyler = function () {
  4192. var _this = this;
  4193. this._styler = new ElementAnimationStyleHandler(this.element, this.animationName, this._duration, this._delay, this.easing, DEFAULT_FILL_MODE, function () { return _this.finish(); });
  4194. };
  4195. /** @internal */
  4196. CssKeyframesPlayer.prototype.triggerCallback = function (phaseName) {
  4197. var methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
  4198. methods.forEach(function (fn) { return fn(); });
  4199. methods.length = 0;
  4200. };
  4201. CssKeyframesPlayer.prototype.beforeDestroy = function () {
  4202. var _this = this;
  4203. this.init();
  4204. var styles = {};
  4205. if (this.hasStarted()) {
  4206. var finished_1 = this._state >= 3 /* FINISHED */;
  4207. Object.keys(this._finalStyles).forEach(function (prop) {
  4208. if (prop != 'offset') {
  4209. styles[prop] = finished_1 ? _this._finalStyles[prop] : computeStyle(_this.element, prop);
  4210. }
  4211. });
  4212. }
  4213. this.currentSnapshot = styles;
  4214. };
  4215. return CssKeyframesPlayer;
  4216. }());
  4217. var DirectStylePlayer = /** @class */ (function (_super) {
  4218. __extends(DirectStylePlayer, _super);
  4219. function DirectStylePlayer(element, styles) {
  4220. var _this = _super.call(this) || this;
  4221. _this.element = element;
  4222. _this._startingStyles = {};
  4223. _this.__initialized = false;
  4224. _this._styles = hypenatePropsObject(styles);
  4225. return _this;
  4226. }
  4227. DirectStylePlayer.prototype.init = function () {
  4228. var _this = this;
  4229. if (this.__initialized || !this._startingStyles)
  4230. return;
  4231. this.__initialized = true;
  4232. Object.keys(this._styles).forEach(function (prop) {
  4233. _this._startingStyles[prop] = _this.element.style[prop];
  4234. });
  4235. _super.prototype.init.call(this);
  4236. };
  4237. DirectStylePlayer.prototype.play = function () {
  4238. var _this = this;
  4239. if (!this._startingStyles)
  4240. return;
  4241. this.init();
  4242. Object.keys(this._styles)
  4243. .forEach(function (prop) { return _this.element.style.setProperty(prop, _this._styles[prop]); });
  4244. _super.prototype.play.call(this);
  4245. };
  4246. DirectStylePlayer.prototype.destroy = function () {
  4247. var _this = this;
  4248. if (!this._startingStyles)
  4249. return;
  4250. Object.keys(this._startingStyles).forEach(function (prop) {
  4251. var value = _this._startingStyles[prop];
  4252. if (value) {
  4253. _this.element.style.setProperty(prop, value);
  4254. }
  4255. else {
  4256. _this.element.style.removeProperty(prop);
  4257. }
  4258. });
  4259. this._startingStyles = null;
  4260. _super.prototype.destroy.call(this);
  4261. };
  4262. return DirectStylePlayer;
  4263. }(NoopAnimationPlayer));
  4264. var KEYFRAMES_NAME_PREFIX = 'gen_css_kf_';
  4265. var TAB_SPACE = ' ';
  4266. var CssKeyframesDriver = /** @class */ (function () {
  4267. function CssKeyframesDriver() {
  4268. this._count = 0;
  4269. this._head = document.querySelector('head');
  4270. this._warningIssued = false;
  4271. }
  4272. CssKeyframesDriver.prototype.validateStyleProperty = function (prop) { return validateStyleProperty(prop); };
  4273. CssKeyframesDriver.prototype.matchesElement = function (element, selector) {
  4274. return matchesElement(element, selector);
  4275. };
  4276. CssKeyframesDriver.prototype.containsElement = function (elm1, elm2) { return containsElement(elm1, elm2); };
  4277. CssKeyframesDriver.prototype.query = function (element, selector, multi) {
  4278. return invokeQuery(element, selector, multi);
  4279. };
  4280. CssKeyframesDriver.prototype.computeStyle = function (element, prop, defaultValue) {
  4281. return window.getComputedStyle(element)[prop];
  4282. };
  4283. CssKeyframesDriver.prototype.buildKeyframeElement = function (element, name, keyframes) {
  4284. keyframes = keyframes.map(function (kf) { return hypenatePropsObject(kf); });
  4285. var keyframeStr = "@keyframes " + name + " {\n";
  4286. var tab = '';
  4287. keyframes.forEach(function (kf) {
  4288. tab = TAB_SPACE;
  4289. var offset = parseFloat(kf['offset']);
  4290. keyframeStr += "" + tab + offset * 100 + "% {\n";
  4291. tab += TAB_SPACE;
  4292. Object.keys(kf).forEach(function (prop) {
  4293. var value = kf[prop];
  4294. switch (prop) {
  4295. case 'offset':
  4296. return;
  4297. case 'easing':
  4298. if (value) {
  4299. keyframeStr += tab + "animation-timing-function: " + value + ";\n";
  4300. }
  4301. return;
  4302. default:
  4303. keyframeStr += "" + tab + prop + ": " + value + ";\n";
  4304. return;
  4305. }
  4306. });
  4307. keyframeStr += tab + "}\n";
  4308. });
  4309. keyframeStr += "}\n";
  4310. var kfElm = document.createElement('style');
  4311. kfElm.innerHTML = keyframeStr;
  4312. return kfElm;
  4313. };
  4314. CssKeyframesDriver.prototype.animate = function (element, keyframes, duration, delay, easing, previousPlayers, scrubberAccessRequested) {
  4315. if (previousPlayers === void 0) { previousPlayers = []; }
  4316. if (scrubberAccessRequested) {
  4317. this._notifyFaultyScrubber();
  4318. }
  4319. var previousCssKeyframePlayers = previousPlayers.filter(function (player) { return player instanceof CssKeyframesPlayer; });
  4320. var previousStyles = {};
  4321. if (allowPreviousPlayerStylesMerge(duration, delay)) {
  4322. previousCssKeyframePlayers.forEach(function (player) {
  4323. var styles = player.currentSnapshot;
  4324. Object.keys(styles).forEach(function (prop) { return previousStyles[prop] = styles[prop]; });
  4325. });
  4326. }
  4327. keyframes = balancePreviousStylesIntoKeyframes(element, keyframes, previousStyles);
  4328. var finalStyles = flattenKeyframesIntoStyles(keyframes);
  4329. // if there is no animation then there is no point in applying
  4330. // styles and waiting for an event to get fired. This causes lag.
  4331. // It's better to just directly apply the styles to the element
  4332. // via the direct styling animation player.
  4333. if (duration == 0) {
  4334. return new DirectStylePlayer(element, finalStyles);
  4335. }
  4336. var animationName = "" + KEYFRAMES_NAME_PREFIX + this._count++;
  4337. var kfElm = this.buildKeyframeElement(element, animationName, keyframes);
  4338. document.querySelector('head').appendChild(kfElm);
  4339. var specialStyles = packageNonAnimatableStyles(element, keyframes);
  4340. var player = new CssKeyframesPlayer(element, keyframes, animationName, duration, delay, easing, finalStyles, specialStyles);
  4341. player.onDestroy(function () { return removeElement(kfElm); });
  4342. return player;
  4343. };
  4344. CssKeyframesDriver.prototype._notifyFaultyScrubber = function () {
  4345. if (!this._warningIssued) {
  4346. console.warn('@angular/animations: please load the web-animations.js polyfill to allow programmatic access...\n', ' visit http://bit.ly/IWukam to learn more about using the web-animation-js polyfill.');
  4347. this._warningIssued = true;
  4348. }
  4349. };
  4350. return CssKeyframesDriver;
  4351. }());
  4352. function flattenKeyframesIntoStyles(keyframes) {
  4353. var flatKeyframes = {};
  4354. if (keyframes) {
  4355. var kfs = Array.isArray(keyframes) ? keyframes : [keyframes];
  4356. kfs.forEach(function (kf) {
  4357. Object.keys(kf).forEach(function (prop) {
  4358. if (prop == 'offset' || prop == 'easing')
  4359. return;
  4360. flatKeyframes[prop] = kf[prop];
  4361. });
  4362. });
  4363. }
  4364. return flatKeyframes;
  4365. }
  4366. function removeElement(node) {
  4367. node.parentNode.removeChild(node);
  4368. }
  4369. var WebAnimationsPlayer = /** @class */ (function () {
  4370. function WebAnimationsPlayer(element, keyframes, options, _specialStyles) {
  4371. this.element = element;
  4372. this.keyframes = keyframes;
  4373. this.options = options;
  4374. this._specialStyles = _specialStyles;
  4375. this._onDoneFns = [];
  4376. this._onStartFns = [];
  4377. this._onDestroyFns = [];
  4378. this._initialized = false;
  4379. this._finished = false;
  4380. this._started = false;
  4381. this._destroyed = false;
  4382. this.time = 0;
  4383. this.parentPlayer = null;
  4384. this.currentSnapshot = {};
  4385. this._duration = options['duration'];
  4386. this._delay = options['delay'] || 0;
  4387. this.time = this._duration + this._delay;
  4388. }
  4389. WebAnimationsPlayer.prototype._onFinish = function () {
  4390. if (!this._finished) {
  4391. this._finished = true;
  4392. this._onDoneFns.forEach(function (fn) { return fn(); });
  4393. this._onDoneFns = [];
  4394. }
  4395. };
  4396. WebAnimationsPlayer.prototype.init = function () {
  4397. this._buildPlayer();
  4398. this._preparePlayerBeforeStart();
  4399. };
  4400. WebAnimationsPlayer.prototype._buildPlayer = function () {
  4401. var _this = this;
  4402. if (this._initialized)
  4403. return;
  4404. this._initialized = true;
  4405. var keyframes = this.keyframes;
  4406. this.domPlayer =
  4407. this._triggerWebAnimation(this.element, keyframes, this.options);
  4408. this._finalKeyframe = keyframes.length ? keyframes[keyframes.length - 1] : {};
  4409. this.domPlayer.addEventListener('finish', function () { return _this._onFinish(); });
  4410. };
  4411. WebAnimationsPlayer.prototype._preparePlayerBeforeStart = function () {
  4412. // this is required so that the player doesn't start to animate right away
  4413. if (this._delay) {
  4414. this._resetDomPlayerState();
  4415. }
  4416. else {
  4417. this.domPlayer.pause();
  4418. }
  4419. };
  4420. /** @internal */
  4421. WebAnimationsPlayer.prototype._triggerWebAnimation = function (element, keyframes, options) {
  4422. // jscompiler doesn't seem to know animate is a native property because it's not fully
  4423. // supported yet across common browsers (we polyfill it for Edge/Safari) [CL #143630929]
  4424. return element['animate'](keyframes, options);
  4425. };
  4426. WebAnimationsPlayer.prototype.onStart = function (fn) { this._onStartFns.push(fn); };
  4427. WebAnimationsPlayer.prototype.onDone = function (fn) { this._onDoneFns.push(fn); };
  4428. WebAnimationsPlayer.prototype.onDestroy = function (fn) { this._onDestroyFns.push(fn); };
  4429. WebAnimationsPlayer.prototype.play = function () {
  4430. this._buildPlayer();
  4431. if (!this.hasStarted()) {
  4432. this._onStartFns.forEach(function (fn) { return fn(); });
  4433. this._onStartFns = [];
  4434. this._started = true;
  4435. if (this._specialStyles) {
  4436. this._specialStyles.start();
  4437. }
  4438. }
  4439. this.domPlayer.play();
  4440. };
  4441. WebAnimationsPlayer.prototype.pause = function () {
  4442. this.init();
  4443. this.domPlayer.pause();
  4444. };
  4445. WebAnimationsPlayer.prototype.finish = function () {
  4446. this.init();
  4447. if (this._specialStyles) {
  4448. this._specialStyles.finish();
  4449. }
  4450. this._onFinish();
  4451. this.domPlayer.finish();
  4452. };
  4453. WebAnimationsPlayer.prototype.reset = function () {
  4454. this._resetDomPlayerState();
  4455. this._destroyed = false;
  4456. this._finished = false;
  4457. this._started = false;
  4458. };
  4459. WebAnimationsPlayer.prototype._resetDomPlayerState = function () {
  4460. if (this.domPlayer) {
  4461. this.domPlayer.cancel();
  4462. }
  4463. };
  4464. WebAnimationsPlayer.prototype.restart = function () {
  4465. this.reset();
  4466. this.play();
  4467. };
  4468. WebAnimationsPlayer.prototype.hasStarted = function () { return this._started; };
  4469. WebAnimationsPlayer.prototype.destroy = function () {
  4470. if (!this._destroyed) {
  4471. this._destroyed = true;
  4472. this._resetDomPlayerState();
  4473. this._onFinish();
  4474. if (this._specialStyles) {
  4475. this._specialStyles.destroy();
  4476. }
  4477. this._onDestroyFns.forEach(function (fn) { return fn(); });
  4478. this._onDestroyFns = [];
  4479. }
  4480. };
  4481. WebAnimationsPlayer.prototype.setPosition = function (p) { this.domPlayer.currentTime = p * this.time; };
  4482. WebAnimationsPlayer.prototype.getPosition = function () { return this.domPlayer.currentTime / this.time; };
  4483. Object.defineProperty(WebAnimationsPlayer.prototype, "totalTime", {
  4484. get: function () { return this._delay + this._duration; },
  4485. enumerable: true,
  4486. configurable: true
  4487. });
  4488. WebAnimationsPlayer.prototype.beforeDestroy = function () {
  4489. var _this = this;
  4490. var styles = {};
  4491. if (this.hasStarted()) {
  4492. Object.keys(this._finalKeyframe).forEach(function (prop) {
  4493. if (prop != 'offset') {
  4494. styles[prop] =
  4495. _this._finished ? _this._finalKeyframe[prop] : computeStyle(_this.element, prop);
  4496. }
  4497. });
  4498. }
  4499. this.currentSnapshot = styles;
  4500. };
  4501. /** @internal */
  4502. WebAnimationsPlayer.prototype.triggerCallback = function (phaseName) {
  4503. var methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
  4504. methods.forEach(function (fn) { return fn(); });
  4505. methods.length = 0;
  4506. };
  4507. return WebAnimationsPlayer;
  4508. }());
  4509. var WebAnimationsDriver = /** @class */ (function () {
  4510. function WebAnimationsDriver() {
  4511. this._isNativeImpl = /\{\s*\[native\s+code\]\s*\}/.test(getElementAnimateFn().toString());
  4512. this._cssKeyframesDriver = new CssKeyframesDriver();
  4513. }
  4514. WebAnimationsDriver.prototype.validateStyleProperty = function (prop) { return validateStyleProperty(prop); };
  4515. WebAnimationsDriver.prototype.matchesElement = function (element, selector) {
  4516. return matchesElement(element, selector);
  4517. };
  4518. WebAnimationsDriver.prototype.containsElement = function (elm1, elm2) { return containsElement(elm1, elm2); };
  4519. WebAnimationsDriver.prototype.query = function (element, selector, multi) {
  4520. return invokeQuery(element, selector, multi);
  4521. };
  4522. WebAnimationsDriver.prototype.computeStyle = function (element, prop, defaultValue) {
  4523. return window.getComputedStyle(element)[prop];
  4524. };
  4525. WebAnimationsDriver.prototype.overrideWebAnimationsSupport = function (supported) { this._isNativeImpl = supported; };
  4526. WebAnimationsDriver.prototype.animate = function (element, keyframes, duration, delay, easing, previousPlayers, scrubberAccessRequested) {
  4527. if (previousPlayers === void 0) { previousPlayers = []; }
  4528. var useKeyframes = !scrubberAccessRequested && !this._isNativeImpl;
  4529. if (useKeyframes) {
  4530. return this._cssKeyframesDriver.animate(element, keyframes, duration, delay, easing, previousPlayers);
  4531. }
  4532. var fill = delay == 0 ? 'both' : 'forwards';
  4533. var playerOptions = { duration: duration, delay: delay, fill: fill };
  4534. // we check for this to avoid having a null|undefined value be present
  4535. // for the easing (which results in an error for certain browsers #9752)
  4536. if (easing) {
  4537. playerOptions['easing'] = easing;
  4538. }
  4539. var previousStyles = {};
  4540. var previousWebAnimationPlayers = previousPlayers.filter(function (player) { return player instanceof WebAnimationsPlayer; });
  4541. if (allowPreviousPlayerStylesMerge(duration, delay)) {
  4542. previousWebAnimationPlayers.forEach(function (player) {
  4543. var styles = player.currentSnapshot;
  4544. Object.keys(styles).forEach(function (prop) { return previousStyles[prop] = styles[prop]; });
  4545. });
  4546. }
  4547. keyframes = keyframes.map(function (styles) { return copyStyles(styles, false); });
  4548. keyframes = balancePreviousStylesIntoKeyframes(element, keyframes, previousStyles);
  4549. var specialStyles = packageNonAnimatableStyles(element, keyframes);
  4550. return new WebAnimationsPlayer(element, keyframes, playerOptions, specialStyles);
  4551. };
  4552. return WebAnimationsDriver;
  4553. }());
  4554. function supportsWebAnimations() {
  4555. return typeof getElementAnimateFn() === 'function';
  4556. }
  4557. function getElementAnimateFn() {
  4558. return (isBrowser() && Element.prototype['animate']) || {};
  4559. }
  4560. /**
  4561. * @license
  4562. * Copyright Google Inc. All Rights Reserved.
  4563. *
  4564. * Use of this source code is governed by an MIT-style license that can be
  4565. * found in the LICENSE file at https://angular.io/license
  4566. */
  4567. /**
  4568. * @license
  4569. * Copyright Google Inc. All Rights Reserved.
  4570. *
  4571. * Use of this source code is governed by an MIT-style license that can be
  4572. * found in the LICENSE file at https://angular.io/license
  4573. */
  4574. /**
  4575. * @license
  4576. * Copyright Google Inc. All Rights Reserved.
  4577. *
  4578. * Use of this source code is governed by an MIT-style license that can be
  4579. * found in the LICENSE file at https://angular.io/license
  4580. */
  4581. /**
  4582. * @license
  4583. * Copyright Google Inc. All Rights Reserved.
  4584. *
  4585. * Use of this source code is governed by an MIT-style license that can be
  4586. * found in the LICENSE file at https://angular.io/license
  4587. */
  4588. /**
  4589. * Generated bundle index. Do not edit.
  4590. */
  4591. export { SpecialCasedStyles as ɵangular_packages_animations_browser_browser_a, AnimationDriver, AnimationDriver as ɵAnimationDriver, Animation as ɵAnimation, AnimationStyleNormalizer as ɵAnimationStyleNormalizer, NoopAnimationStyleNormalizer as ɵNoopAnimationStyleNormalizer, WebAnimationsStyleNormalizer as ɵWebAnimationsStyleNormalizer, NoopAnimationDriver as ɵNoopAnimationDriver, AnimationEngine as ɵAnimationEngine, CssKeyframesDriver as ɵCssKeyframesDriver, CssKeyframesPlayer as ɵCssKeyframesPlayer, containsElement as ɵcontainsElement, invokeQuery as ɵinvokeQuery, matchesElement as ɵmatchesElement, validateStyleProperty as ɵvalidateStyleProperty, WebAnimationsDriver as ɵWebAnimationsDriver, supportsWebAnimations as ɵsupportsWebAnimations, WebAnimationsPlayer as ɵWebAnimationsPlayer, allowPreviousPlayerStylesMerge as ɵallowPreviousPlayerStylesMerge };
  4592. //# sourceMappingURL=browser.js.map