function applyFocusBehavior(e){if(null===e.onmousedown){let t=!1;e.onmousedown=function(){t=!0},e.onmouseup=function(){t=!1},e.onfocus=function(){var e;t?this.select():(e=this.value.length,this.setSelectionRange(e,e))}}}function setClass(t,o,n){if(void 0!==t.classList)n?t.classList.add(o):t.classList.remove(o);else{let e=t.className.split(" ");var s=e.indexOf(o);n?s<0?e.push(o):e=void 0:s<0?e=void 0:e.splice(s,1),void 0!==e&&(t.className=e.join(" "))}}function isOverflow(e){e=getComputedStyle(e);switch(e.overflowX){case"auto":case"scroll":return!0}switch(e.overflowY){case"auto":case"scroll":return!0}return!1}function deriveOverflowRegion(t){if(null===t)t=document.documentElement;else if(!isOverflow(t))return;return{scrollIntoView(e){e.right>t.scrollLeft+t.clientWidth&&(t.scrollLeft=e.right-t.clientWidth),e.left<t.scrollLeft&&(t.scrollLeft=e.left),e.bottom>t.scrollTop+t.clientHeight&&(t.scrollTop=e.bottom-t.clientHeight),e.top<t.scrollTop&&(t.scrollTop=e.top)}}}function extentOf(e,t){if(void 0===t)return{left:e.offsetLeft,top:e.offsetTop,right:e.offsetLeft+e.offsetWidth+e.scrollWidth-e.clientWidth,bottom:e.offsetTop+e.offsetHeight+e.scrollHeight-e.clientHeight};var o=e.offsetLeft+e.clientLeft,e=e.offsetTop+e.clientTop;return{left:o+t.left,top:e+t.top,right:o+t.right,bottom:e+t.bottom}}function scrollIntoView(e){let t;for(;e instanceof HTMLElement;){t=extentOf(e,t);const o=deriveOverflowRegion(e.offsetParent);if(void 0!==o){o.scrollIntoView(t);break}e=e.offsetParent}}function captureMouseEvents(o){let n=!1;function s(e){return o(e),n=!0,e.stopPropagation(),e.preventDefault(),!1}addEventListener("mousemove",s,!0),addEventListener("mouseup",function e(t){if(removeEventListener("mousemove",s,!0),removeEventListener("mouseup",e,!0),n)return o(void 0),t.stopPropagation(),t.preventDefault(),!1},!0)}export{applyFocusBehavior,setClass,scrollIntoView,captureMouseEvents};