define(["events","playbackManager","dom","browser","css!./iconosd","material-icons"],function(events,playbackManager,dom,browser){"use strict";var currentPlayer,osdElement,iconElement,progressElement,enableAnimation,hideTimeout;function onHideComplete(e){e.target===e.currentTarget&&this.classList.contains("iconOsd-hidden")&&this.classList.add("hide")}function clearHideTimeout(){hideTimeout&&(clearTimeout(hideTimeout),hideTimeout=null)}function hideOsd(){clearHideTimeout();var elem=osdElement;elem&&(enableAnimation?(elem.offsetWidth,elem.classList.add("iconOsd-hidden")):onHideComplete.call(elem))}function onBrightnessChanged(e){!function(){var elem=osdElement;elem||(enableAnimation=browser.supportsCssAnimation(),(elem=document.createElement("div")).classList.add("hide"),elem.classList.add("iconOsd"),elem.classList.add("iconOsd-hidden"),elem.classList.add("brightnessOsd"),elem.innerHTML='<i class="md-icon iconOsdIcon">&#xE1AC;</i><div class="iconOsdProgressOuter"><div class="iconOsdProgressInner brightnessOsdProgressInner"></div></div>',iconElement=elem.querySelector("i"),progressElement=elem.querySelector(".iconOsdProgressInner"),document.body.appendChild(elem),osdElement=elem,dom.addEventListener(elem,dom.whichTransitionEvent(),onHideComplete,{passive:!0}))}(),function(brightness){iconElement&&(iconElement.innerHTML=80<=brightness?"&#xE1AC;":20<=brightness?"&#xE1AE;":"&#xE1AD;"),progressElement&&(progressElement.style.width=(brightness||0)+"%")}(playbackManager.getBrightness(this)),function(){clearHideTimeout();var elem=osdElement;elem.classList.remove("hide"),elem.offsetWidth,elem.classList.remove("iconOsd-hidden"),hideTimeout=setTimeout(hideOsd,3e3)}()}function bindToPlayer(player){player!==currentPlayer&&(function(){var player=currentPlayer;player&&(events.off(player,"brightnesschange",onBrightnessChanged),events.off(player,"playbackstop",hideOsd),currentPlayer=null)}(),(currentPlayer=player)&&(hideOsd(),events.on(player,"brightnesschange",onBrightnessChanged),events.on(player,"playbackstop",hideOsd)))}events.on(playbackManager,"playerchange",function(){bindToPlayer(playbackManager.getCurrentPlayer())}),bindToPlayer(playbackManager.getCurrentPlayer())});