(function(){var e=function(e){var t=this;e.require().script("mvc/dom.range","mvc/controller","mvc/event.livehack").done(function(){var n=function(){var t=e.event;t.selection={delay:300,preventDefault:t.supportTouch},t.setupHelper(["selectionStart","selectionEnd","selectionEnding","selectionMoving","selectionMove"],"mousedown",function(n){var r=n.delegateTarget||n.currentTarget,i=n.handleObj.selector,s=!1,o=this,u=e.Range(n),a=function(t){var n=e.Range(t),r=u.compare("START_TO_START",n),i;return r==-1||r==0?u.clone().move("END_TO_END",n):n.clone().move("END_TO_END",u)},f=function(){e(r).unbind("mousemove",c).unbind("mouseup",l),clearTimeout(p),u=null},l=function(u){if(!s){f();return}e.each(t.find(r,["selectionMoving"],i),function(){this.call(o,u,l)});var l=a(u);f(),e.each(t.find(r,["selectionEnd"],i),function(){this.call(o,n,l)})},c=function(u){if(u.clientX==n.clientX&&u.clientY==n.clientY)return;if(!s)return f();e.each(t.find(r,["selectionMoving"],i),function(){this.call(o,u,l)});var l=a(u);e.each(t.find(r,["selectionMove"],i),function(){this.call(o,u,l)})},h=function(){s=!0;var a=t.selection.preventDefault?e.Event("selectionStart"):n,a=e.extend(n,a);e.each(t.find(r,["selectionStart"],i),function(){this.call(o,a,u)}),t.selection.preventDefault&&a.isDefaultPrevented()&&(s=!1,f())},p;t.selection.preventDefault?(n.preventDefault(),p=setTimeout(h,t.selection.delay)):h(),e(r).bind("mousemove",c).bind("mouseup",l)})};n(),t.resolveWith(n)})};dispatch("mvc/event.selection").containing(e).to("Foundry/2.1 Modules")})();