define(["inputManager","focusManager","browser","layoutManager","events","dom"],function(inputmanager,focusManager,browser,layoutManager,events,dom){"use strict";function mouseIdleTime(){return(new Date).getTime()-lastMouseInputTime}function notifyApp(){inputmanager.notifyMouseMove()}function onPointerMove(e){var pointerType=e.pointerType||(layoutManager.mobile?"touch":"mouse");if("mouse"===pointerType){var eventX=e.screenX,eventY=e.screenY;if("undefined"==typeof eventX&&"undefined"==typeof eventY)return;var obj=lastPointerMoveData;if(!obj)return void(lastPointerMoveData={x:eventX,y:eventY});if(Math.abs(eventX-obj.x)<10&&Math.abs(eventY-obj.y)<10)return;obj.x=eventX,obj.y=eventY,lastMouseInputTime=(new Date).getTime(),notifyApp(),isMouseIdle&&(isMouseIdle=!1,document.body.classList.remove("mouseIdle"),events.trigger(self,"mouseactive"))}}function onPointerEnter(e){var pointerType=e.pointerType||(layoutManager.mobile?"touch":"mouse");if("mouse"===pointerType&&!isMouseIdle){var parent=focusManager.focusableParent(e.target);parent&&focusManager.focus(e.target)}}function enableFocusWithMouse(){return!!layoutManager.tv&&(!browser.web0s&&!!browser.tv)}function onMouseInterval(){!isMouseIdle&&mouseIdleTime()>=5e3&&(isMouseIdle=!0,document.body.classList.add("mouseIdle"),events.trigger(self,"mouseidle"))}function startMouseInterval(){mouseInterval||(mouseInterval=setInterval(onMouseInterval,5e3))}function stopMouseInterval(){var interval=mouseInterval;interval&&(clearInterval(interval),mouseInterval=null),document.body.classList.remove("mouseIdle")}function initMouse(){stopMouseInterval(),dom.removeEventListener(document,window.PointerEvent?"pointermove":"mousemove",onPointerMove,{passive:!0}),layoutManager.mobile||(startMouseInterval(),dom.addEventListener(document,window.PointerEvent?"pointermove":"mousemove",onPointerMove,{passive:!0})),dom.removeEventListener(document,window.PointerEvent?"pointerenter":"mouseenter",onPointerEnter,{capture:!0,passive:!0}),enableFocusWithMouse()&&dom.addEventListener(document,window.PointerEvent?"pointerenter":"mouseenter",onPointerEnter,{capture:!0,passive:!0})}var isMouseIdle,lastPointerMoveData,mouseInterval,self={},lastMouseInputTime=(new Date).getTime();return initMouse(),events.on(layoutManager,"modechange",initMouse),self});