/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{createClass as e,classCallCheck as t,defineProperty as s}from"../../_virtual/_rollupPluginBabelHelpers.js";var n="press",r="pressend",o="doubleclick",i="click",a="touchmove",c="touchstart",h="touchend",l={start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},u={start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"};function v(e){return e&&e.length>0?e[e.length-1]:null}var d=/* @__PURE__ */function(){function d(e){var n=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{eventType:"touch"};t(this,d),s(this,"onTouchStart",function(e){var t=n._pos,s=n.root,r=v(e.touches);t.x=r?parseInt(r.pageX,10):e.pageX,t.y=r?parseInt(r.pageX,10):e.pageX,t.start=!0,n.__setPress(e),s.addEventListener(n.events.end,n.onTouchEnd),s.addEventListener(n.events.cancel,n.onTouchCancel),s.addEventListener(n.events.move,n.onTouchMove),n.trigger(c,e)}),s(this,"onTouchCancel",function(e){n.onTouchEnd(e)}),s(this,"onTouchEnd",function(e){var t=n._pos,s=n.root;n.__clearPress(),s.removeEventListener(n.events.cancel,n.onTouchCancel),s.removeEventListener(n.events.end,n.onTouchEnd),s.removeEventListener(n.events.move,n.onTouchMove),e.moving=t.moving,e.press=t.press,t.press&&n.trigger(r,e),n.trigger(h,e),!t.press&&!t.moving&&n.__setDb(e),t.press=!1,t.start=!1,t.moving=!1}),s(this,"onTouchMove",function(e){var t=n._pos,s=n.config,o=v(e.touches),i=o?parseInt(o.pageX,10):e.pageX,c=o?parseInt(o.pageY,10):e.pageX,h=i-t.x,l=c-t.y;Math.abs(l)<s.miniStep&&Math.abs(h)<s.miniStep||(n.__clearPress(),t.press&&n.trigger(r,e),t.press=!1,t.moving=!0,n.trigger(a,e))}),this._pos={moving:!1,start:!1,x:0,y:0},this.config={pressDelay:600,dbClickDelay:200,disablePress:!1,disableDbClick:!1,miniStep:2,needPreventDefault:!0},Object.keys(o).map(function(e){n.config[e]=o[e]}),this.root=e,this.events="mouse"===o.eventType?u:l,this.pressIntrvalId=null,this.dbIntrvalId=null,this.__handlers={},this._initEvent()}return e(d,[{key:"_initEvent",value:function(){this.root.addEventListener(this.events.start,this.onTouchStart)}},{key:"__setPress",value:function(e){var t=this,s=this.config;this.pressIntrvalId&&this.__clearPress(),this.pressIntrvalId=setTimeout(function(){t.trigger(n,e),t._pos.press=!0,t.__clearPress()},s.pressDelay)}},{key:"__clearPress",value:function(){window.clearTimeout(this.pressIntrvalId),this.pressIntrvalId=null}},{key:"__setDb",value:function(e){var t=this,s=this.config;if(this.dbIntrvalId)return this.__clearDb(),void this.trigger(o,e);this.dbIntrvalId=setTimeout(function(){t.__clearDb(),t._pos.start||t._pos.press||t._pos.moving||t.trigger(i,e)},s.dbClickDelay)}},{key:"__clearDb",value:function(){clearTimeout(this.dbIntrvalId),this.dbIntrvalId=null}},{key:"on",value:function(e,t){this.__handlers[e]||(this.__handlers[e]=[]),this.__handlers[e].push(t)}},{key:"off",value:function(e,t){if(this.__handlers[e]){for(var s=this.__handlers[e],n=-1,r=0;r<s.length;r++)if(s[r]===t){n=r;break}n>=0&&this.__handlers[e].splice(n,1)}}},{key:"trigger",value:function(e,t){this.__handlers[e]&&this.__handlers[e].map(function(s){try{s(t)}catch(n){console.error("trigger>>:".concat(e),n)}})}},{key:"destroy",value:function(){var e=this,t={touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart"};Object.keys(t).forEach(function(s){e.root.removeEventListener(s,e[t[s]])})}}]),d}();export{d as default};