/**
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
part of the polymer project is also subject to an additional IP rights grant
found at http://polymer.github.io/PATENTS.txt
*/
import"../polymer/polymer-legacy.js";import{NeonAnimatableBehavior as n}from"./neon-animatable-behavior.js";export const NeonAnimationRunnerBehaviorImpl={_configureAnimations:function(n){var i=[],e=[];if(n.length>0)for(let i,t=0;i=n[t];t++){let n=document.createElement(i.name);if(n.isNeonAnimation){let t=null;n.configure||(n.configure=function(n){return null}),t=n.configure(i),e.push({result:t,config:i,neonAnimation:n})}else console.warn(this.is+":",i.name,"not found!")}for(var t=0;t<e.length;t++){let n=e[t].result,o=e[t].config,a=e[t].neonAnimation;try{"function"!=typeof n.cancel&&(n=document.timeline.play(n))}catch(i){n=null,console.warn("Couldnt play","(",o.name,").",i)}n&&i.push({neonAnimation:a,config:o,animation:n})}return i},_shouldComplete:function(n){for(var i=!0,e=0;e<n.length;e++)if("finished"!=n[e].animation.playState){i=!1;break}return i},_complete:function(n){for(var i=0;i<n.length;i++)n[i].neonAnimation.complete(n[i].config);for(i=0;i<n.length;i++)n[i].animation.cancel()},playAnimation:function(n,i){var e=this.getAnimationConfig(n);if(e){this._active=this._active||{},this._active[n]&&(this._complete(this._active[n]),delete this._active[n]);var t=this._configureAnimations(e);if(0!=t.length){this._active[n]=t;for(var o=0;o<t.length;o++)t[o].animation.onfinish=function(){this._shouldComplete(t)&&(this._complete(t),delete this._active[n],this.fire("neon-animation-finish",i,{bubbles:!1}))}.bind(this)}else this.fire("neon-animation-finish",i,{bubbles:!1})}},cancelAnimation:function(){for(var n in this._active){var i=this._active[n];for(var e in i)i[e].animation.cancel()}this._active={}}};export const NeonAnimationRunnerBehavior=[n,NeonAnimationRunnerBehaviorImpl];